For line graphs, the current baseline implementation is confusing to me. The value seems to be taken as a value from
0 to max, then normalized to the max value, giving a 0 to 1 distribution, which is then mapped to the graph (0=bottom,
1=top).
This works well if your minimum value is 0 -- on a graph of 0 to 10, a baseline value of 5 would put a line in the middle,
at the value 5. If your graph starts at a negative value, this produces weird results.
All of my graphs go from a negative min to positive max, and I wanted to put a baseline at the value 0, so I used this
function:
min = g.minimum_value
max = g.maximum_value
g.baseline_value = (-1*min*max)/(max - min)
unless I'm getting my math wrong, this function would put the baseline at any specified value:
y = given_value
g.baseline_value = ((y-min)*max)/(max - min)
it would be nice if the baseline_value function worked as I described above, so that no matter what your min or max
are, it would put the line at the specified value (unless I am missing the point of how to use it correctly). |