PrevorCZ / flot

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

Negative bars which go past the min of the y-axis are not shown. #36

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Place the attached file in the examples dir of the flot distribution and
open.

What is the expected output? What do you see instead?
The third bar has a value of -2, which is below the min y-axis value. Its
not shown on the graph. It should be.

What version of the product are you using? On what operating system?
Flot-0.4

Please provide any additional information below.

Problem is on line 1191-1194:
var left = x, right = x + barWidth, bottom = 0, top = y;

if (right < xaxis.min || left > xaxis.max || top < yaxis.min || bottom >
yaxis.max)
  continue;

On a negative bar, top is the bottom of the rectangle to draw, and bottom
is the top, so this logic fails. Top and bottom should be swapped so that
the clip code below this continues to work. For example, change 1191 from:
var left = x, right = x + barWidth, bottom = 0, top = y;
to:
var left = x, right = x + barWidth, bottom = (y < 0 ? y : 0), top = (y < 0
? 0 : y);

Original issue reported on code.google.com by james.he...@gmail.com on 18 May 2008 at 4:10

Attachments:

GoogleCodeExporter commented 9 years ago
Not 3rd bar, that should say 5th.

Original comment by james.he...@gmail.com on 18 May 2008 at 4:10

GoogleCodeExporter commented 9 years ago
For convenience, here's a patch for this change, which looks good to me.

Original comment by ryan.fun...@gmail.com on 28 May 2008 at 3:51

Attachments:

GoogleCodeExporter commented 9 years ago
Patch applied cleanly. Thanks to both of you!

Original comment by olau%iol...@gtempaccount.com on 8 Sep 2008 at 9:23

GoogleCodeExporter commented 9 years ago
Hm, patch didn't work quite as intended, it didn't draw the outline correctly on
negative bars. I've fixed it now.

Original comment by olau%iol...@gtempaccount.com on 21 Sep 2008 at 9:01