我有一个dxPieChart,但是我想在单击按钮时更改数据源,然后应再次创建dxpiechart。
$("#pie").dxPieChart({
type: "doughnut",
palette: "Soft Pastel",
dataSource: dataSource,
title: "The Population of Continents and Regions",
tooltip: {
enabled: true,
format: "millions",
customizeTooltip: function (arg) {
var percentText = Globalize.formatNumber(arg.percent, {
style: "percent",
minimumFractionDigits: 2,
maximumFractionDigits: 2
});
return {
text: arg.valueText + " - " + percentText
};
}
},
legend: {
horizontalAlignment: "right",
verticalAlignment: "top",
margin: 0
},
"export": {
enabled: true
},
series: [{
argumentField: "region",
label: {
visible: true,
format: "millions",
connector: {
visible: true
}
}
}]
数据来自dataSource,但是当我单击按钮时,它应该来自dataSource2 不幸的是,这就是我尝试过的方法
$("#widget2").dxButton({
//"icon": "favorites",
"text": "",
onClick: function(e) {
var a=x.getDataSource();
if (y.style.display === "none") {
y.style.display = "block";
} else {
y.style.display = "none";
}
}