剑道未举办活动 [英] Event does not fire up in Kendo

查看:96
本文介绍了剑道未举办活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

mouse hover事件不会触发.我无法弄清楚

The mouse hover event does not fire up. 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/

推荐答案

有时您需要学习调试兄弟,这不是未触发悬停功能,而是您粗心地编写了代码.

You need to learn to debug sometimes bro, it wasn't the hover function not triggered but you just write a code carelessly.

图表选项中的series属性是array.因此,您需要一个索引才能访问它.另外,由于打算更改系列而不是其数据,因此必须在更改系列数据后立即调用redraw方法.

The series property in chart's options is an 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.

此代码将起作用

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!!

这篇关于剑道未举办活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆