nvd3.js tooltip position with multiple charts

前端 未结 3 1876
眼角桃花
眼角桃花 2020-12-20 18:28

I\'m usinging v1.7.1 of nvd3. I have a page in which I render rows of charts with the same configuration but different data. I\'m using interactive tooltip option on the m

3条回答
  •  情话喂你
    2020-12-20 18:52

    I had a similar problem. The current implementation of the nvd3's native showTooltip method looks as follows:

    var showTooltip = function(e, offsetElement) {
      var left = e.pos[0] + ( offsetElement.offsetLeft || 0),
        top = e.pos[1] + ( offsetElement.offsetTop || 0),
        x = xAxis.tickFormat()(multibar.x()(e.point, e.pointIndex)),
        y = yAxis.tickFormat()(multibar.y()(e.point, e.pointIndex)),
        content = tooltip(e.series.key, x, y, e, chart);
    
      nv.tooltip.show([left, top], content, e.value < 0 ? 'e' : 'w', null, offsetElement);
    };
    

    The implementation mis-align tooltips in different ways. So I've modified the behavior which fixed the problem for me. You can check out my fork https://github.com/ovvn/nvd3/blob/master/build/nv.d3.js

提交回复
热议问题