Question

I am trying to have my own y axis labels for the bubble chart in nvd3. Currently the labels are [1,2,3,4,5]. I want them to be displayed as [2,4,8,16,32]. I found the following function,

chart.yAxis.tickValues(['2','4','8','16','32']);

But the labels are not being changed here. I am unable to understand why.

Était-ce utile?

La solution

These tick values will not have any effect if the y values themselves are not within the 2-32 range. Right now that chart only has y values up to 2+.

So, if in addition to adding chart.yAxis.tickValues(['2','4','8','16','32']); to the Chart Code/Javascript tab as you have in your question, you also make the following change to the code in the Data(JSON) tab...

y: Math.floor(Math.random() * 33) // change from y: random()

...then you will see the tick values you specified (2-32) show up in the y axis.

NOTE: I assume you are looking at the Scatter / Bubble Chart.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top