Closed rkofman closed 9 years ago
We're in the process of revamping tooltip API. Hold off until https://github.com/novus/nvd3/pull/851
Right now, it's only:
{
value: xValue,
series: allData
}
and I'd like to propose passing in pointIndex
as well, to bring it up to par with
data: d,
index: i,
color: d3.select(this).style("fill")
That gets passed to the regular tooltips.
(I can make a quick PR with the diff, if that seems reasonable)
Yea, we an extend it further, but lets get this large PR merged first... hopefully today or tomorrow unless someone finds a bug.
Okay, it has been merged, please send up a pull request and I'll close this issue out, thanks!
[Not sure if this falls more on the support request side (and belongs on StackOverflow), or if it's more of a feature refinement request. Please accept my apologies if this is the wrong forum.]
I might be doing something silly, but I'm having some trouble figuring out how to best provide custom tooltips for the
stackedAreaChart
. Trying to dochart.tooltips(true).tooltipContent(function(){return "foo";})
seems to fail due toscatter.interactive(false);
in: https://github.com/novus/nvd3/blob/development/src/models/stackedArea.js#L29So, I try using
chart.useInteractiveGuideline(true); chart.interactiveLayer.tooltip.contentGenerator(function(){return "asdf";})
, which seems to work -- but I don't get the same access to variables that I do in most chart'stooltipContent
functions, such askey, x, y, e, graph
. Instead I only get the formattedxValue
, and aseries
. This makes it much harder to build a custom tooltip (my x axis formatter is destructive, so I can't guarantee being able to get back to the unformatted X value).The only way I can see of overriding what's provided to that function is providing my own
interactiveLayer
to the chart, and implementinginteractiveLayer.dispatch.on('elementMousemove', function(e) {
to provide my own custom data to thecontentGenerator
function (https://github.com/novus/nvd3/blob/development/src/models/stackedAreaChart.js#L330).Is there a simpler way? Hopefully, one that ties into the
tooltipShow
dispatch event... if not, I'd like to request it be added :)