8

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 Answer 1

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

5
  • throws error like this Uncaught TypeError: Cannot read property 'valueFormatter' of undefined Jul 23, 2015 at 8:37
  • Which version of nvd3.js are you using?
    – Lioman
    Jul 23, 2015 at 8:38
  • 1
    You should upgrade. v1.8.1 had some tooltip changes.
    – al lin
    Jul 23, 2015 at 8:42
  • 1.8.1 is in alpha state.. not sure if it is stable enough.. 1.7.1 is the last stable release. is'nt it possible to do it in this version?? Jul 23, 2015 at 8:48
  • No 1.8.1 it is not in alpha state, it is the current realease
    – Lioman
    Jul 23, 2015 at 8:50

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.