javascript - Method Trigger in Kendo -
i have dummy data in following jsfiddle : http://jsfiddle.net/epvg86qu/18/ , when user clicks on line, calls detailchart_click()
method draws other data series (stats,stats2)
, viceversa.
however when try implement functionality (seriesclick
) in actual project, calls detailchart_click()
method once when initialize.however, not call/trigger method when user clicks on line series.
var ishover=false; self.updatechart = function () { var chart = $("#chart").data("kendochart"); chart.options.series = self.dataseries1; chart.options.seriesclick = detailchart_click(); chart.refresh(); } function detailchart_click() { console.log("hello"); if (!ishover) { var chart = $("#chart").data("kendochart"); chart.options.series = self.dataseries2; chart.redraw(); ishover = true; } else if (ishover) { var chart = $("#chart").data("kendochart"); chart.options.series = self.dataseries1; chart.redraw(); ishover = false; } }
you can use below snippet bind detailchart_click()
after initialization:
var chart = $("#chart").data("kendochart"); chart.bind("seriesclick", detailchart_click);
taken here.
alternatively, bind during initialization shown in demo.
additional note
what doing below:
chart.options.seriesclick = detailchart_click();
is calling detailchart_click
function , assign return value (which undefined
has no return value) seriesclick
, not want. if want register callbacks such one, you'd want omit parentheses (which makes reference function detailchart_click
) , assign seriesclick
, intended do.
however, if remove parentheses in code above, assigned wrongly, seriesclick
callback should registered bind
method of chart
, instead of assigning options
property of chart
.
hope helps!
Comments
Post a Comment