Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>EDIT: The response down below is more correct!</p> <p><a href="https://stackoverflow.com/a/8408466/387285">https://stackoverflow.com/a/8408466/387285</a></p> <p><a href="http://www.highcharts.com/ref/#series-object" rel="nofollow noreferrer">http://www.highcharts.com/ref/#series-object</a> </p> <p>HTML:</p> <pre><code>&lt;SELECT id="list"&gt; &lt;OPTION VALUE="A"&gt;Data Set A &lt;OPTION VALUE="B"&gt;Data Set B &lt;/SELECT&gt; &lt;button id="change"&gt;Refresh Table&lt;/button&gt; &lt;div id="container" style="height: 400px"&gt;&lt;/div&gt; </code></pre> <p>Javascript:</p> <pre><code>var options = { chart: { renderTo: 'container', defaultSeriesType: 'spline' }, series: [] }; $("#change").click(function() { if ($("#list").val() == "A") { options.series = [{name: 'A', data: [1,2,3,2,1]}] // $.get('/dough/includes/live-chart.php?mode=month' } else { options.series = [{name: 'B', data: [3,2,1,2,3]}] // $.get('/dough/includes/live-chart.php?mode=newmode' } var chart = new Highcharts.Chart(options); }); </code></pre> <p>This is a very simple example since I don't have my files here with me but the basic idea is that every time the user selects new options for the stuff they want to see, you're going to have replace the .series data object with the new information from your server and then recreate the chart using the new Highcharts.Chart();.</p> <p>Hope this helps! John</p> <p>EDIT:</p> <p>Check this out, its from something I've worked on in the past:</p> <pre><code>$("table#tblGeneralInfo2 &gt; tbody &gt; tr").each(function (index) { if (index != 0) { var chartnumbervalue = parseInt($(this).find("td:last").text()); var charttextvalue = $(this).find("td:first").text(); chartoptions.series[0].data.push([charttextvalue, chartnumbervalue]); } }); </code></pre> <p>I had a table with information in the first and last tds that I needed to add to the pie chart. I loop through each of the rows and push in the values. Note: I use chartoptions.series[0].data since pie charts only have 1 series.</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