HumbleSoftware / Flotr2

Graphs and Charts for Canvas in JavaScript.
http://www.humblesoftware.com/flotr2/
MIT License
2.45k stars 528 forks source link

Need an option to prevent run of hit.closest #231

Open NisSAM opened 11 years ago

NisSAM commented 11 years ago

I have created my own chart type that has its own hit function. But when it doesn't find closest point hit.closest function fires while I need to stop search here.

I need a way (some option) to prevent hit.closest function run even if the hit in custom type found nothing.

cesutherland commented 11 years ago

Could you create a fiddle as an example? http://jsfiddle.net/cesutherland/ZFBj5/

On Tue, Jul 2, 2013 at 7:52 AM, NisSAM notifications@github.com wrote:

I have created my own chart type that has its own hit function. But when it doesn't find closest point hit.closest function fires while I need to stop search here.

I need a way (some option) to prevent hit.closest function run even if the hit in custom type found nothing.

— Reply to this email directly or view it on GitHubhttps://github.com/HumbleSoftware/Flotr2/issues/231 .

NisSAM commented 11 years ago

Carl, it is very difficult because I use a very unusual type plugin written by myself. But the problem is the if (options.mouse.trackY && !options.mouse.trackAll && this.hit.executeOnType(this.series, 'hit', [mouse, n]) && !_.isUndefined(n.seriesIndex)) { series = this.series[n.seriesIndex]; n.series = series; n.mouse = series.mouse; n.xaxis = series.xaxis; n.yaxis = series.yaxis; } else {

  closest = this.hit.closest(mouse);

If we didn't fill n.seriesIndex hit plugin will run closest = this.hit.closest(mouse); line. I need a way to prevent it. Of course I can just comment this line but I will need to do this with every flort2 update. That's all.

cesutherland commented 11 years ago

OK I think I understand the issue. It is using the default hit method if it is not finding a hit within your chart type. Is that correct?

On Tue, Jul 2, 2013 at 8:34 AM, NisSAM notifications@github.com wrote:

Carl, it is very difficult because I use a very unusual type plugin written by myself. But the problem is the if (options.mouse.trackY && !options.mouse.trackAll && this.hit.executeOnType(this.series, 'hit', [mouse, n]) && !_.isUndefined(n.seriesIndex)) { series = this.series[n.seriesIndex]; n.series = series; n.mouse = series.mouse; n.xaxis = series.xaxis; n.yaxis = series.yaxis; } else {

closest = this.hit.closest(mouse);

If we didn't fill n.seriesIndex hit plugin will run closest = this.hit.closest(mouse); line. I need a way to prevent it. Of course I can just comment this line but I will need to do this with every flort2 update. That's all.

— Reply to this email directly or view it on GitHubhttps://github.com/HumbleSoftware/Flotr2/issues/231#issuecomment-20343005 .

NisSAM commented 11 years ago

Yes, you are right.

cesutherland commented 11 years ago

I think this is enough to solve it: in the if conditions, check that there is a hit method on the configured chart types instead of checking for an actual hit.

What kind of graph have you created? I'd still be interested to see, even if it's a screen shot.

On Tue, Jul 2, 2013 at 8:38 AM, NisSAM notifications@github.com wrote:

Yes, you are right.

— Reply to this email directly or view it on GitHubhttps://github.com/HumbleSoftware/Flotr2/issues/231#issuecomment-20343154 .

NisSAM commented 11 years ago

For me your fix will be OK but I am not sure about others.

I'll send the archive with the graph later to you e-mail.

NisSAM commented 11 years ago

I've found a dirty temporary solution

Flotr.plugins.hit.closest = function (mouse) {return false};