youcef92 / flotr

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

autoscaleMargin causes error if chart is empty #111

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
If you draw an empty chart:
-----
options = {"yaxis": {"autoscaleMargin": 0.1}};

series = [
{label: "Serie 1", color: "#00A8F0", data:
 [[0, 0],[1, 0],[2, 0],[3, 0],[4, 0],[5, 0]], xaxis: 1, yaxis: 1}
];
-----

The autoscaleMargin causes an error.

What is the expected output? What do you see instead?

I would expect to see the same chart as without autoscaleMargin. Instead
the chart is only half-drawn and there is an error in console:
-----
Error: [Exception... "An invalid or illegal string was specified"  code:
"12" nsresult: "0x8053000c (NS_ERROR_DOM_SYNTAX_ERR)"  location:
"http://phenxdesign.net/projects/flotr/flotr/prototype/flotr.js Line: 2503"]
Source File: http://phenxdesign.net/projects/flotr/flotr/prototype/flotr.js
Line: 2503
-----

What version of the product are you using? On what operating system?
Using current playground and r471 (locally). Firefox, Linux.

I am attaching two images:
1) without autoscalemargin, as one would expect to see it
2) with autoscaleMargin - chart is not ok. 

This problem is serious for me because I have no way of knowing in advance
what the data will be - it is created dynamically. The charts look nicer
with autoscaleMargin, but if it doesn't work in every case... :(

I would appreciate some feedback. 

Kind regards!

Original issue reported on code.google.com by anz...@gmail.com on 24 Dec 2009 at 8:46

Attachments:

GoogleCodeExporter commented 8 years ago
Here is the solution:

change line in function calculateRange():
  if(max > 0 && axis.datamax <= 0) max = 0;
to:
  if(max > 0 && axis.datamax <= 0 && axis.datamax != axis.datamin) max = 0; 

The problem was that both min and max were set to 0 if autoscaleMargin was set, 
which
caused problems elsewhere. 

PLEASE add this to the trunk - as well as other bug fixes I have contributed. I 
would
hate to have to re-apply them whenever the new version comes out. 

Original comment by anz...@gmail.com on 24 Dec 2009 at 10:24

GoogleCodeExporter commented 8 years ago
Thank you, fixed in the next revision.

Original comment by fabien.menager on 16 Jul 2010 at 7:26