Update the dataset of multiple AmCharts with a Single Dropdown Change Event

烈酒焚心 提交于 2019-12-12 04:16:45

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!