Home › Forums › Feature Requests & Feedback › Creating Multi Series Chart in AJAX with JSON › Reply To: Creating Multi Series Chart in AJAX with JSON
You can modify and customize chart-options dynamically. Adding another dropdown to filter based on department/course should work fine if you handle chart-options accordingly. Below is the code snippet for the same.
var courseName = document.getElementById('courseName');
courseName.addEventListener( "change", function(){
var dataSeries;
for(var i= 0; i < data.length; i++){
if(data[i].name === courseName.options[courseName.selectedIndex].value){
dataSeries = data[i];
dataSeries.type = selectedChartType;
chart.options.data = [];
chart.options.data.push(dataSeries);
}
else if(courseName.options[courseName.selectedIndex].value === ""){
for(var i = 0; i < data.length; i++){
data[i].type = selectedChartType;
}
chart.options.data = data;
}
}
chart.render();
});
Please take a look at this updated jsfiddle.
—
Vishwas R
Team CanvasJS