I have a barchart made with NVD3
that shows datas with a huge gap between min value and max value.
This makes the chart not really nice/usefull.
Example :
Y value are between 4,000 and 60,000 then some value are near 3m.
I would like to have an Y Axis value increasing logarithmically, that show something like this (see the y Axis):
I tried to change yAxis scale, yAxis Domain, but didn't find any working solution
(FYI: I use nvd3 through angularJs directives)
The root of the issue is that barcharts in nvd3 start at 0, and log(0) == Infinity.
Unfortunately there is a particular line in nvd3 that uses y(0) when calculating the height of the bar for your chart. When y(0) evaluates to Infinity things break. Furthermore, nvd3 is currently undergoing a refactor so, they aren't taking any pull requests for the old code base.
Here is what worked for me. It's not a general soltuion, but I couldn't even find this level of info online so I'm posting it here.
In this case I'm using a Line plus Bar Chart, this may not work for other bar charts, but hopefully it gives you and idea of what needs to be done.
First, make sure your chart is setup properly.
now in nvd3.js around line 1600 (in nvd3 1.8 line number is 5605) you should see:
In the very last statement:
You need to replace y(0) with y(1) which will give you this:
If this doesn't work, look for other cases where nvd3 sets up bars.transition() and calculates the height. You may need to fix up other cases where 0 is passed to y().
Hope this helps.
This will work for you