Search code examples
tooltipnvd3.js

NVD3 tooltip pointer not updating position after updating chart data


I'm using the NVD3 library to draw a graph. I am using the interactive guideline and for some reason after I update the chart data + graph, the tooltip pointers stay at the old position.

tooltip pointer at wrong position

When I update the data I do this:

chartData.datum(data).call(chart);

Everything updates fine except the position of the pointers of the tooltip. They seem to get stuck at the old position. I also tried calling this:

chart.update();

I noticed that when resizing my window and calling chart.update(), the pointers are set to the right position.

Someone any idea how to fix this?


Solution

  • Found it! I apparently had to add transition().duration(500);

    So in order to update the graph I call this:

    chartData.datum(data) .transition().duration(500) .call(chart);