score:2

Accepted answer

How about setting all options (except data and title) in Highcharts.setOptions(options), just like here: http://www.highcharts.com/demo/column-basic/dark-unica

Then create charts:

$('#dashboard').highcharts({
  title: { text: {{ mytext }} },
  series: [{
    type: 'pie',
    name: 'Project share',
    data: [
      ['Bill',  {{ project }}],
      ['Non-Bill', {{ not_bill }}],
    ]
  }]
});
$('#dashboard1').highcharts({
  title: { text: {{ mytext_2 }} },
  series: [{
    type: 'pie',
    name: 'Project share',
    data: [
      ['Bill',  {{ project_2 }}],
      ['Non-Bill', {{ not_bill_2 }}],
    ]
  }]
});

Or even better:

function createChart(container, text, valA, valB) {
  $(container).highcharts({
    title: { text: text },
    series: [{
      type: 'pie',
      name: 'Project share',
      data: [
        ['Bill',   valA ],
        ['Non-Bill', valB ],
      ]
    }]
  });
}

createChart('#dashboard', {{ mytext }}, {{ project }}, {{ not_bill }});
createChart('#dashboard1', {{ mytext_2 }}, {{ project_2 }}, {{ not_bill_2 }});

Related Articles