From 6b3d5f06010f298c82f4ff57dd1fb8fe0bba799c Mon Sep 17 00:00:00 2001 From: Torsten Dreyer Date: Wed, 15 Apr 2015 11:17:12 +0200 Subject: [PATCH] Phi: improve the plot extension - add plothover and plotclick event - add a postupdate hook --- webgui/main.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/webgui/main.js b/webgui/main.js index 36b5571f5..6dcf49979 100644 --- a/webgui/main.js +++ b/webgui/main.js @@ -477,8 +477,13 @@ require([ var value = valueAccessor() || {}; if (value.hover && typeof (value.hover) === 'function') { - $(element).bind("plothover", function(event, pos, item) { - value.hover(pos, item); + jquery(element).bind("plothover", function(event, pos, item) { + value.hover.call(jquery(this).data("flotplot"), pos, item); + }); + } + if (value.click && typeof (value.click) === 'function') { + jquery(element).bind("plotclick", function(event, pos, item) { + value.click.call(jquery(this).data("flotplot"), pos, item); }); } }, @@ -487,7 +492,12 @@ require([ var value = valueAccessor() || {}; var data = ko.unwrap(value.data); var options = ko.unwrap(value.options); - jquery.plot(element, data, options); + var plot = jquery.plot(element, data, options); + jquery(element).data("flotplot", plot ); + var postUpdate = ko.unwrap(value.postUpdate); + if( postUpdate ) { + postUpdate.call( value, element ); + } },