Skip to content

Instantly share code, notes, and snippets.

@Kyeongan
Last active November 29, 2022 10:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kyeongan/a0a405d1f895b48a236335a3f2e04229 to your computer and use it in GitHub Desktop.
Save Kyeongan/a0a405d1f895b48a236335a3f2e04229 to your computer and use it in GitHub Desktop.
Custom tooltip for nvd3
// custom tooltip example
chart.tooltip.contentGenerator(function (obj) {
var format = d3.format(",d");
return '<table><thead><tr><td class=x-value colspan=3><h1 class=tooltip>' + obj.data.name + '</h1></td></tr></thead>' +
'<tbody><tr><td class=key>Impact Factor:</td><td class=value>' + obj.data.meanIF + '</td></tr>' +
'<tr><td class=key>Citations:</td><td class=value>' + format(obj.data.meanCitations) + '</td></tr>' +
'<tr><td class=key>Funding:</td><td class=value>$' + format(obj.data.funding) + '</td></tr>' +
'</tbody></table>'
});
@Kyeongan
Copy link
Author

Kyeongan commented Jun 28, 2016

an example of custom tooltip
screen shot 2016-06-28 at 11 16 14 am

@nhdong1505
Copy link

thanks!

@owenfar
Copy link

owenfar commented Nov 29, 2022

For anyone having problems showing custom tooltips with InteractiveGuideline set to true, you can use the following:

chart.interactiveLayer.tooltip.contentGenerator(function (obj) { ... });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment