gmmoraesbr / flot

Automatically exported from code.google.com/p/flot
0 stars 0 forks source link

Selections can be so small that you can't see them! (Problem and half-assed patch) #366

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
To see what I mean, grab flot 0.6

Open selection demo and change line 108 to 
plot.setSelection({ x1: 1994, x2: 1994 });

Now try the demo: when you click "Select Year 1994" apparently nothing happens!

(I know this is a slightly bad example: from and to the same value? But if you 
put together an example with about ~4500 data points and try to select a range 
of 10 the same problem will occur)

Open jquery.flot.selection.js And add a line at line after line 219:
if (selection.second.x < selection.first.x + 10) selection.second.x = 
selection.first.x + 10;

Just to be clear, now function setSelection() looks like:
            var axis, range, axes = plot.getAxes();
            var o = plot.getOptions();

            if (o.selection.mode == "y") {
                selection.first.x = 0;
                selection.second.x = plot.width();
            }
            else {
                axis = ranges["xaxis"]? axes["xaxis"]: (ranges["x2axis"]? axes["x2axis"]: axes["xaxis"]);
                range = ranges["xaxis"] || ranges["x2axis"] || { from:ranges["x1"], to:ranges["x2"] }
                selection.first.x = axis.p2c(Math.min(range.from, range.to));
                selection.second.x = axis.p2c(Math.max(range.from, range.to));
                if (selection.second.x < selection.first.x + 10) selection.second.x = selection.first.x + 10;

Of course, +10 is a bit hacky, you'll want that constant in a configurable 
option somewhere but you see what I mean ... now even when you select a small 
range, the selection is visible to the user!

Original issue reported on code.google.com by james57....@googlemail.com on 23 Jun 2010 at 10:38

GoogleCodeExporter commented 8 years ago
Hi! I can see where you're coming from - Flot already prevents users from 
making small selections, you can also see there how the 
how-small-a-selection-is-ok problem is solved.

However, it is assumed that when you access it programmatically, you know what 
you're doing, and I think it has to be that way to avoid nasty surprises, e.g. 
when you try to synchronize selections on two charts and they suddenly stop 
behaving properly. So I'm going to wontfix this.

Original comment by olau%iol...@gtempaccount.com on 13 Dec 2010 at 5:51

GoogleCodeExporter commented 8 years ago

Original comment by dnsch...@gmail.com on 4 Jun 2012 at 2:41