通过按钮更改dxPieChart的数据源

时间:2018-09-11 12:46:45

标签: javascript html devexpress

我有一个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";
    }

        }  

0 个答案:

没有答案