voidlabs / elycharts

Interactive Javascript (SVG|VML) Charting Library
http://elycharts.com
Other
10 stars 6 forks source link

axis.min does affect line graphs of positive numbers #29

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Configure axis.l.min as 300
2. Plot a line graph of these values (all > 300): 
[410, 406, 482, 613, 337, 530, 483, 518, 469, 393, 463, 570, 323]

What is the expected output? 
Vertical axis starts at 300
What do you see instead?
Vertical axis starts at 0

What version of the product are you using? v2.1.4-SNAPSHOT
On what operating system? Windows 7, Google Chrome

Please provide any additional information below.
There are two coding issues that together cause this:
1: lines 3137 - 3138:
              for (i = 0; i < showValues.length; i++)
                plot.from.push(0);
This causes minimum value > 0 to be ignored. 
To fix, second line could be replaced by:
                plot.from.push(plot.to[i]);

2. Lines 3219 - 3220:
            if (axis[lidx].min)
              axis[lidx].min = Math.floor(axis[lidx].min / v) * v;
At this point, v is always > axis[lidx].min, thus Math.floor(axis[lidx].min / 
v) is always equal to 0. It appears that it was intended to round to a multiple 
of basev (10 in the example), i.e., the second line could be fixed as:
              axis[lidx].min = Math.floor(axis[lidx].min / basev) * basev;

Original issue reported on code.google.com by b.engelb...@gmail.com on 23 Aug 2013 at 9:58

GoogleCodeExporter commented 9 years ago
I found that my modification at lines 3137 - 3138 did not work for graph types 
other than "line". To fix that, second line should be:
  plot.from.push((props.type == 'line') ? plot.to[i] : 0);

Original comment by b.engelb...@gmail.com on 28 Aug 2013 at 2:44

GoogleCodeExporter commented 9 years ago
"axis.l.min" is not intended to define the "START" of the axis.
It is instead intended to define a minimum value for the "END" of the axis.

So if your values are all lower than 300 and your chart is "automatically" 
labeled with a maximum value of, lets say, 100, using axis.l.min you can tell 
elycharts to still use 300 for the end value of the l axis.

This is useful when you have multiple charts and you want them to be on the 
same "l" scale.

What you are asking is instead to have the chart starting from a value 
different than "0" and this is not supported by elychart.

If you need this feature it should be opened as a feature and a patch should 
include a new parameter, not a change on the "min" property that is already 
serving a different goal.

Original comment by stefano....@gmail.com on 5 Feb 2014 at 7:52