kendoui图表甜甜圈设置亮点

时间:2017-03-06 17:31:15

标签: javascript kendo-ui kendo-chart donut-chart

我有一个剑道ui图表甜甜圈,我想设置不透明度的“路径”:在绘图时刻通过阅读一个参数,在我的情况下,参数是“活跃的”我试过写“视觉”功能但从未被执行......

我尝试过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();
            }
        });

有人知道如何在特定的“路径”上设置opacity = 0.5吗?非常感谢你的帮助!

2 个答案:

答案 0 :(得分:2)

在该系列的视觉属性中,您可以这样做:

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

<强> DEMO

答案 1 :(得分:0)

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

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

Live Demo