问题
I currently have 2 AMCharts on the same page and a single dropdown with values 2015,2016,2017,2018 in it.
I have followed this example to dynamically update the data in the bar chart http://www.amcharts.com/tips/dynamically-loading-chart-datasets/
I also have a Pie Chart and would like to update the data with the same drop down but I am not sure how to connect it so that it also updates at the same time.
Any suggestions ?
回答1:
Just expand the function that changes the dataset of the charts with your pie chart reference.
function setDataSet( dataset_url ) {
// chart2 should be the reference to your pie chart
chart.dataProvider = chart2.dataProvider = AmCharts.loadJSON( dataset_url );
chart.validateData();
chart2.validateData();
}
EDIT: Here is a working demo.
来源:https://stackoverflow.com/questions/34808991/update-the-dataset-of-multiple-amcharts-with-a-single-dropdown-change-event