最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - nvd3 tooltip decimal format - Stack Overflow

programmeradmin1浏览0评论

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?

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?

Share Improve this question edited Jul 23, 2015 at 8:15 Sunil Kumar B M asked Jul 23, 2015 at 7:59 Sunil Kumar B MSunil Kumar B M 2,7951 gold badge27 silver badges32 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 10

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 ponent in VCD3.js

发布评论

评论列表(0)

  1. 暂无评论