nvd3工具提示十进制格式 [英] nvd3 tooltip decimal format

查看:67
本文介绍了nvd3工具提示十进制格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用nvd3显示折线图。

I'm using nvd3 to display line graph.

格式化工具提示内容有点麻烦

Having a little trouble in formatting the tooltip content

这是我用来格式化y轴文本的行

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

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

但是,它只在y轴生效。
如果有一个像44.123231的值,在y轴,它将显示为44.12,但在工具提示,它显示44.00。
可能是什么问题?
在nvd3中有一种方式来格式化工具提示文本?

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?

推荐答案

可以使用 .tooltip.valueFormatter()指定格式化函数。

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

看看这个示例在plunker

这是文档 for VCD3.js中的工具提示组件

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

这篇关于nvd3工具提示十进制格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆