Skip to content

Instantly share code, notes, and snippets.

@dphase
Created October 17, 2012 14:07
Show Gist options
  • Save dphase/3905683 to your computer and use it in GitHub Desktop.
Save dphase/3905683 to your computer and use it in GitHub Desktop.
BCG HighChart
// --------------------------------------------------------------------
// BCG Highchart
// --------------------------------------------------------------------
// Creating a new Highchart object for each chart gets very repetitive.
// Using jQuery extend, we can create charts with a predefined set of
// defaults.
//
// EXAMPLE:
//
// var fooChart = {
// chartContent: 'DOM_id_of_element_for_render',
// options: {
// // Custom chart options, place Highchart params here
// chart: { zoomType: 'x' },
// series: [{ data: days }]
// }
// };
//
// fooChart = $.extend(true, {}, bcgChart, fooChart);
// fooChart.init(fooChart.options);
// fooChart.create();
// --------------------------------------------------------------------
var bcgChart = {
chartContent: null,
highchart: null,
defaults: {
chart: {
backgroundColor: 'transparent'
},
credits : { enabled: false },
exporting : {
buttons: {
exportButton: { enabled: false },
printButton: { enabled: false }
}
},
series: []
},
init: function(options) {
this.highchart = jQuery.extend({}, this.defaults, options);
this.highchart.chart.renderTo = this.chartContent;
},
create: function() {
new Highcharts.Chart(this.highchart);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment