简体   繁体   中英

Flot chart combined tooltip of multiple series

I have a flot chart with multiple series. I need to show y-values of all the series together when any point is hovered on for a particular x-value.

I'm using flot.tooltip for showing the tooltip. Is there any way to combine the y-values of all series like PowerBI does? Or or maybe even trigger the hovers of other points too?

Here's what I included in my chartOptions:

tooltipOpts: {
    content: function (label, x, y) {
        // titile
        var text = "<i>" + vm.areaData[0].data[x][0] + '<br/></i>';
        vm.areaData.forEach(function(series)
        {
            // series_label : value
            text += "<b>" + series.label + ' : ' + series.data[x][1] + "<br/>" + "</b>";
        });
        return text;
    }
}

As the X-axis has common values, I'm using that as title for the tooltip. vm.areaData has the different series that are on my chart. I'm iterating through them and creating the tooltip that needs to be displayed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM