Highcharts custom renderer chart and tooltip

懵懂的女人 提交于 2019-12-06 00:10:03

Now we have a working version (thx Pawel!!!):

  1. problem: some rectangulars are not connected; solution: all plotX and plotY coordinates have to be rounded before you do calculations with them.

  2. problem: missmatch of individual borders and rectangulars; solution: again rounding did the trick

  3. problem: a) mousemove for custom rendered tooltip b) bind tooltip on hover event for label and rectangular; solution: a) reject custom tooltip idea instead bind highcharts tooltip of corresponding data point on hover event for rectangular b) create a ghost (completely transparent) for each rectangular and bind hover event on it

    //draw ghost for each rectangular and bind tooltip of highcharts on it
    for (var i = 0; i < points.length; i++) {
    
        var ghostRect = chart.renderer.rect(xAll[i], yAll[i], widthAll[i], heightAll[i], 0)
            .attr({
            id: i,
            'stroke-width': 0,
            stroke: 'rgba(255, 255, 255, 0)',
            fill: 'rgba(255, 255, 255, 0)',
            zIndex: 10
        })
            .add()
            .on('mouseover', function () {
                 var index = parseInt(this.getAttribute('id'));
                 var point = chart.series[0].points[index];
                 chart.tooltip.refresh(point);
        })
            .on('mouseout', function () {
                 chart.tooltip.hide();
        });
    
    
    };
    

    Here is the working fiddle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!