novus / nvd3

A reusable charting library written in d3.js
http://nvd3.org/
Other
7.22k stars 2.15k forks source link

calcTicksY invalid if only one data set #918

Open tarioch opened 9 years ago

tarioch commented 9 years ago

Hi,

I use a stacked multi bar chart with only one "stack" of data.

so the data looks like this

[ { key: 'Apples', values: [{x: "", y: 300}] }, { key: 'Oranges', values: [{x: "", y: 250}] }, { key: 'Bananas', values: [{x: "", y: 100}] } ]

Now as the function calcTicksY is implemented as just using calcTicksX it's not adding ticks. (calcTicksX is looking at the max number of values).

liquidpele commented 9 years ago

So wait, is calcXTicks() returning zero in this case?

tarioch commented 9 years ago

It's returning 1, when it should be returning the argument number of ticks (which is calculated based on the height). So in the end shows only the minimal and maximal value and no ticks. The thing is that we are showing numerical values, so why should it depend on the number of data entries, that for me only makes sense for non numerical values.

liquidpele commented 9 years ago

Yea, then that's correct, that was a fix for the axis showing multiple ticks with the same value. It won't do more ticks than there are values.

tarioch commented 9 years ago

But that doesn't make any sense whatsoever for the Y axis in the diagram. On the one side it's a numeric value so ticks make sense even if there would only be one value. On the other hand I actually have multiple values (Apples, Oranges, Bananas, ...)

tarioch commented 9 years ago

I created a jsfiddle for it with an old version: http://jsfiddle.net/z4aZ4/380/ with a new version: http://jsfiddle.net/z4aZ4/382/

liquidpele commented 9 years ago

Yea, that's a side effect of making sure that the data points don't duplicate... if you want more ticks, you can override that value by doing chart.yAxis.ticks(8) or whatever though :)

liquidpele commented 9 years ago

although, it was really more for line/scatter stuff... maybe that dosn't apply as much to stacked bar. I'll play with it and see if it was really an issue for that chart or not. If it wasn't, we can probably revert it back to the previous logic...