Created
October 17, 2012 14:07
-
-
Save dphase/3905683 to your computer and use it in GitHub Desktop.
BCG HighChart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// -------------------------------------------------------------------- | |
// 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