【问题标题】:kendoui chart donut set highlight剑道 ui 图表甜甜圈集突出显示
【发布时间】:2017-03-06 17:31:14
【问题描述】:

我有一个剑道 ui 图表甜甜圈,我想通过读取参数在绘图时刻设置不透明度为 0.5 的“路径”,在我的情况下,参数是“活动的”我尝试编写“视觉”功能但永远不会被执行...

我已尝试使用 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?非常感谢大家的帮助!

【问题讨论】:

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


    【解决方案1】:

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

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

    DEMO

    【讨论】:

    • 我已使用您的解决方案设置不透明度以进行更改。
    • 伟大而优雅的解决方案,我在剑道文档中找不到...我使用该代码修改了爆炸甜甜圈项目的边框颜色。
    【解决方案2】:

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

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

    Live Demo

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多