nvd3 tooltip decimal format

柔情痞子 提交于 2019-12-10 12:56:05

问题


I'm using nvd3 to display line graph.

Having a little trouble in formatting the tooltip content

This is the line I'm using to format the y-axis text

chart1.yAxis.tickFormat(d3.format('.02f'));

But, it is only taking effect on the y-axis. If there is a value like 44.123231, in y-axis, it will show up like 44.12, but in the tooltip, it is showing 44.00. What could be the issue? Is there a way in nvd3 to format tooltip text?


回答1:


You can use chart.tooltip.valueFormatter() to specify a formatting function.

Look at this example on Plunker in script.js line 29.

Here is the documentation for the tooltip component in VCD3.js



来源:https://stackoverflow.com/questions/31581400/nvd3-tooltip-decimal-format

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