Note that there are some explanatory texts on larger screens.

plurals
  1. POSetData() not working on Change Event HighCharts Pie Chart
    text
    copied!<p>I'm looking for a way to dynamically update data in a highcharts pie chart based on the change event on a dropdownlist. I have seen a couple examples but I am really unable to figure out why I can't get this working. Here is my whole code, I wrap my stuff inside a function so I can call the function with the Change() event of the dropdownlist, but I get the error of CRIPT438: Object doesn't support property or method 'setData'</p> <pre><code>function showClass(){ var total = 0; var options = { chart:{type:'pie', renderTo: 'ctl00_ContentPlaceHolder1_Overview1_tcAssetAllocation_body', events: { load: function(event) { $('.highcharts-legend-item').last().append('&lt;br/&gt;&lt;div style="width:220px"&gt;&lt;hr/&gt; &lt;span style="float:left"&gt; Total &lt;/span&gt;&lt;span style="float:right"&gt;100%&lt;/span&gt; &lt;/div&gt;') } } }, credits:{enabled: false}, colors:[ '#5485BC', '#AA8C30', '#5C9384', '#981A37', '#FCB319', '#86A033', '#614931', '#00526F', '#594266', '#cb6828', '#aaaaab', '#a89375' ], title:{text: null}, tooltip:{ enabled: true, animation: true }, plotOptions: { pie: { allowPointSelect: true, animation: true, cursor: 'pointer', showInLegend: true, dataLabels: { enabled: false, formatter: function() { return this.percentage.toFixed(2) + '%'; } } } }, legend: { enabled: true, layout: 'vertical', align: 'right', width: 220, verticalAlign: 'top', borderWidth: 0, useHTML: true, labelFormatter: function() { total += this.y; return '&lt;div style="width:200px"&gt;&lt;span style="float:left"&gt;' + this.name + '&lt;/span&gt;&lt;span style="float:right"&gt;' + this.y + '%&lt;/span&gt;&lt;/div&gt;'; }, title: { text: 'Primary', style: { fontWeight: 'bold' } } }, series: [{ type: 'pie', data: [['Domestic Equity', 38.5],['International Equity', 26.85],['Other', 15.70],['Cash and Equivalents', 10.48],['Fixed Income', 8.48]] }] } var chart = new Highcharts.Chart(options); $("#ctl00_ContentPlaceHolder1_Overview1_AccountList1_ddlAccounts").change(function(){ var selVal = $("#ctl00_ContentPlaceHolder1_Overview1_AccountList1_ddlAccounts").val(); if(selVal == '1124042'){ chart.series[0].setData([['Domestic Equity', 18.5], ['International Equity', 46.85], ['Other', 5.70], ['Cash and Equivalents', 20.48], ['Fixed Income', 8.48]]); } }); </code></pre> <p>}</p> <p>is it because i am nested inside another function? it's jsut that all the fiddles use the document.ready function and it loads properly calling the function in the document.ready() but getting it on the change event is messing with me. Any help is greatly appreciated. Tahnk you very much, NickG</p>
 

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