Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use <code>jQuery.extend()</code> and <code>Highcharts.setOptions</code>.<br> So first you'll make the first object which will be extended by all your charts, this object will contain your Highchart default functions.</p> <p>You can do it using namespacing.<br> <strong>The following way is good when you have very different charts.</strong></p> <p>Default graphic:</p> <pre><code>var defaultChart = { chartContent: null, highchart: null, defaults: { chart: { alignTicks: false, borderColor: '#656565', borderWidth: 1, zoomType: 'x', height: 400, width: 800 }, series: [] }, // here you'll merge the defauls with the object options init: function(options) { this.highchart= jQuery.extend({}, this.defaults, options); this.highchart.chart.renderTo = this.chartContent; }, create: function() { new Highcharts.Chart(this.highchart); } }; </code></pre> <p>Now, if you want to make a column chart, you'll extend defaultChart</p> <pre><code>var columnChart = { chartContent: '#yourChartContent', options: { // your chart options } }; columnChart = jQuery.extend(true, {}, defaultChart, columnChart); // now columnChart has all defaultChart functions // now you'll init the object with your chart options columnChart.init(columnChart.options); // when you want to create the chart you just call columnChart.create(); </code></pre> <p><strong>If you have similar charts use <code>Highcharts.setOptions</code> which will apply the options for all created charts after this.</strong></p> <pre><code>// `options` will be used by all charts Highcharts.setOptions(options); // only data options var chart1 = Highcharts.Chart({ chart: { renderTo: 'container1' }, series: [] }); var chart2 = Highcharts.Chart({ chart: { renderTo: 'container2' }, series: [] }); </code></pre> <p><em>Reference</em></p> <ul> <li><a href="http://api.highcharts.com/highcharts#Highcharts.setOptions%28%29">http://api.highcharts.com/highcharts#Highcharts.setOptions%28%29</a></li> </ul> <p><a href="http://jsfiddle.net/ricardolohmann/YnBNV/"><strong>COMPLETE DEMO</strong></a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload