简体   繁体   English

剑道未举办活动

[英]Event does not fire up in Kendo

The mouse hover event does not fire up. mouse hover事件不会触发。 I could not able to figure that out 我无法弄清楚

function createChart() {
    $("#chart")
        .kendoChart({
            xAxis: {},
            yAxis: {},
            seriesDefaults: {type: "scatterLine" },
            series: [{data: stats2}],
  })
}

// the following part does not fire up
var isHover = false;
$("#chart").hover(
function () {
    if (!isHover) {
        var chart = $("#chart").data().kendoChart;
        chart.options.series.data=stats2;
        isHover = true;
    }
}, function () {
    if (isHover) {
        var chart = $("#chart").data().kendoChart;
        chart.options.series.data=stats;
        isHover = false;
    }
});

http://jsfiddle.net/epvg86qu/7/ http://jsfiddle.net/epvg86qu/7/

You need to learn to debug sometimes bro, it wasn't the hover function not triggered but you just write a code carelessly. 您有时需要学习调试兄弟,这不是没有触发悬停功能,而是您不小心编写了代码。

The series property in chart's options is an array . 图表选项中的series属性是一个array Therefore you need an index to access it. 因此,您需要一个索引才能访问它。 Also because you are intend to change the series instead of its data, you have to call redraw method right after you change series data. 另外,由于打算更改系列而不是其数据,因此必须在更改系列数据后立即调用redraw方法。

This code will work 该代码将起作用

var isHover = false;
$("#chart").hover(
    function () {
    if (!isHover) {
        var chart = $("#chart").data().kendoChart;
        chart.options.series[0].data = stats2;
        chart.redraw();
        isHover = true;
    }
}, function () {
    if (isHover) {
        var chart = $("#chart").data().kendoChart;
        chart.options.series[0].data = stats;
        chart.redraw();
        isHover = false;
    }
});

Have a good day, cheers!! 祝你有美好的一天,干杯!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM