kendo ui 图表甜甜圈设置突出显示

kendoui chart donut set highlight

我有一个 kendo ui 图表甜甜圈,我想在绘图时通过读取参数设置 "path" 不透明度:0.5,在我的例子中是参数是 "active" 我试过编写 "visual" 函数但从未执行过...

我试过使用 toggleHighlight 但没有用。

$("#chart").kendoChart({
            chartArea: {
                width: 440,
                height:300
            },
            seriesDefaults: {
                labels: {
                    template: "# if(dataItem.active) { #☑# } else { #☐# }# #= kendo.format('{0:P}', percentage)#",
                    position: "outsideEnd",
                    visible: true,
                    background: "transparent",
                    font: "14px Verdana"
                },
                opacity: 1
            },
            series: [{
                type: "donut",
                data: [{
                    category: "Football",
                    value: 35,
                    active: false
                }, {
                    category: "Basketball",
                    value: 25,
                    active: false
                }, {
                    category: "Volleyball",
                    value: 20,
                    active: true
                }],
                highlight: {
                    visible: true,
                    opacity: 0.5,
                    toggle: function (e) {
                        e.preventDefault();
                        var opacity = e.dataItem.active ? 0.5 : 1;
                        e.visual.opacity(opacity);
                    }
                },
                visual: function (e) {
                    console.log("visual");
                    console.log(e);
                }
            }],
            seriesClick: function (e) {
                debugger;
                console.log(e);
                var $this = this;

                var series = $this.options.series[0].data;
                for (var i = 0; i < series.length; i++) {
                    if (series[i].category == e.category) {
                        series[i].active = !series[i].active;
                        if (series[i].active) {
                            console.log("TOOGLE");
                        }
                    }
                }
                //this.setOptions({ series: series });
                this.refresh();
            }
        });

有人知道如何在特定 "path" 上设置不透明度=0.5?非常感谢大家的帮助!

在此代码中,如果您设置边框不透明度意味着它将影响

$("#chart").kendoChart({
  series: [{
      type: "pie",
      data: [1, 2],
      highlight: {
        border: {
          opacity: 0.5,
          width: 5,
          color: "black"
        }
      }
  }]
});

Live Demo

在系列的视觉属性中,可以这样操作:

visual: function (e) {
    var opacity = e.dataItem.active ? 0.5 : 1;
    e.options.opacity=opacity;
    var v = e.createVisual();
    return v;
}

DEMO