faheem801 / flot

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

add option to set min y-value for filled area graphs #418

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Problem:
area graphs always fill to a y-value of '0', even for plots with negative 
y-values. this is not always desired; sometimes its necessary to fill entire 
area below line graph from y-value of line to minimum y-value of axis.

according to the flot API documentation:

"Lines and points take two coordinates. For filled lines and bars, you can 
specify a third coordinate which is the bottom of the filled area/bar (defaults 
to 0)."

however, this feature hasn't been implemented as of version 0.6 & doesnt yet 
work.

Solution:
allow user to set minimum value for area fills

at approx line #158 in jquery.flot.js:
function plotLineArea(datapoints, axisx, axisy) {
    var points = datapoints.points,ps = datapoints.pointsize,
    bottom = Math.min(Math.max(0, axisy.min), axisy.max),
    top, lastX = 0, areaOpen = false;

so, implement method to set a custom 'bottom' value.
my hack was to set 'bottom' to 'axisy.min' in order to fill plot line area 
completely to bottom of axis.

Original issue reported on code.google.com by changos...@gmail.com on 15 Sep 2010 at 7:33

GoogleCodeExporter commented 9 years ago
I have a related issue with default fill to 0.

When I have only 1 filled graph, the Y axis always starts from 0, even if the 
data is in the range of 40-100 (see flot-filled.png). If I add another curve 
(not filled), then the y axis gets auto-minimum set correctly, see 
flot_filled_and_line.png .

I changed the line mentioned by changosurf  to bottom = axisy.min , but I still 
get the graph filled up to 0 if I only have 1 filled curve.

Looks like yaxis.min is not determined correctly, but I couldn't find where.

Original comment by mila.bol...@gmail.com on 20 Oct 2010 at 2:58

Attachments:

GoogleCodeExporter commented 9 years ago
To those who might be interested: to force flot compute nminnimum valuye on the 
Y axis when filled to default (0), you may want to add [null,null] as last 
datapoint of your filled graph.

The Y-min is the set correctly to the range that is visible on the graph.

Original comment by mila.bol...@gmail.com on 11 Dec 2010 at 7:40

GoogleCodeExporter commented 9 years ago
changosurf: Try the development version, you might have read something from the 
documentation for that.

mila.boldareva: could you please try with the development version here:

http://flot.googlecode.com/svn/trunk/

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

GoogleCodeExporter commented 9 years ago
thank you,
i will try the new dev version a.s.a.p. and report back.

Original comment by mila.bol...@gmail.com on 16 Dec 2010 at 5:40

GoogleCodeExporter commented 9 years ago
I have tested the development version from the trunk as of 19 January, but I 
still get the same result as above.

Original comment by mila.bol...@gmail.com on 19 Jan 2011 at 2:22

GoogleCodeExporter commented 9 years ago
Mila: your case sounds like issue 450. I suggest you star that, there's some 
analysis in it.

Original comment by olau%iol...@gtempaccount.com on 2 Feb 2011 at 11:53