How can i change highcharts data values by selecting from a dropdown list
highcharts, ruby-on-rails
Solution
Got it....
For complete code click here
var options = {
chart: {
renderTo: 'container',
defaultSeriesType: 'spline'
},
series: [{name: 'A', data: [1,2,3,2,1]}]
};
var chart = new Highcharts.Chart(options);
$("#list").on('change', function(){
//alert('f')
var selVal = $("#list").val();
if(selVal == "A" || selVal == '')
{
options.series = [{name: 'A', data: [1,2,3,2,1]}]
}
else if(selVal == "B")
{
options.series = [{name: 'B', data: [3,2,1,2,3]}]
}
else if(selVal == "C")
{
options.series = [{name: 'C', data: [5,4,8,7,6]}]
}
else
{
options.series = [{name: 'D', data: [4,7,9,6,2]}]
}
var chart = new Highcharts.Chart(options);
});
Problem
I am trying to make a highchart for different fruit types. I want to make a dropdown list of some fruits and when the user selects one of the fruits then the graph changes according to that fruit. I cant find any example for dropdown list in highcharts documentation, does highcharts allows a dropdown list?