change y axis labels in nvd3 scatter-chart

╄→гoц情女王★ 提交于 2019-12-02 03:23:54

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/23461979/change-y-axis-labels-in-nvd3-scatter-chart

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!