ico icon indicating copy to clipboard operation
ico copied to clipboard

Incorrect graph with all zero values

Open juhamust opened this issue 13 years ago • 5 comments

The graph is shown incorrectly when all the values are zero:

  • Line graph: straight line above the graph, no labels
  • Bar graph: all full bars
  • Etc.

Expected outcome is have flat line/bars at level 0.

var placeholder = document.getElementById('graph');

// var values = [0, 1, 4, 3];  // <-- OK
var values = [0, 0, 0, 0];  // <-- NOK
new Ico.LineGraph(placeholder, values, 
{colour:'#ff0000', labels:['one', 'two', 'three', 'four'], height:300, width: 300}
);

Used versions:

  • Ico (latest from master): 15e69ac4da850c0639f1569f2f408e0b57471b86
  • Raphael.js: 2.0.1

juhamust avatar Feb 07 '12 17:02 juhamust

I'll take a look

alexyoung avatar Feb 08 '12 10:02 alexyoung

The values were coming out as NaN

alexyoung avatar Feb 08 '12 14:02 alexyoung

I just pushed a fix for this, let me know if it does what you want.

alexyoung avatar Feb 08 '12 14:02 alexyoung

Looks quite good: Line graph is shown as expected, but bar graph is not showing any bars (it could show flat bars at zero level as well).

However, I'm fine with the current solution - thanks for the quick response and fix!

juhamust avatar Feb 08 '12 18:02 juhamust

Yeah, I think the bar should show at least a line at zero else it might be misread as a missing value rather than 0. I'll keep this open until I figure that out.

alexyoung avatar Feb 09 '12 10:02 alexyoung