Highcharts (multiple graph tooltip display)

Asked 2 years ago, Updated 2 years ago, 132 views

For example, if you display multiple graphs on the same scale on the x-axis as in the previous year and this year, please tell me how to display multiple graph values on one tooltip.When you hover your cursor over a graph, you may see one value and multiple values, which is indefinite.

Current tooltip settings

 tooltip: {
           crosshairs —true
          , shared —true
          , pointFormat: '<span style="color:{series.color}">{series.name}:</span>{point.y}<br>'
       }

highcharts

2022-09-29 22:44

1 Answers

Try tooltip.shared=true.

http://api.highcharts.com/highcharts#tooltip.shared

When applied to a demo of bar-basic, the following is true:

$(function(){
    $('#container').highcharts({
        chart: {
            type: 'bar'
        },
        title: {
            text: 'Historic World Population by Region'
        },
        subtitle: {
            text:'Source:<a href="https://en.wikipedia.org/wiki/World_population">Wikipedia.org</a>'
        },
        xAxis: {
            categories: ['Africa', 'America', 'Asia', 'Europe', 'Oceania',
            title: {
                text —Null
            }
        },
        yAxis: {
            min : 0,
            title: {
                text: 'Population (millions),
                align: 'high'
            },
            labels:{
                overflow: 'justify'
            }
        },
        tooltip: {
            valueSuffix: 'millions',
            shared —true
        },
        plotOptions: {
            bar:{
                dataLabels: {
                    enabled —true
                }
            }
        },
        legend: {
            layout: 'vertical',
            align: 'right',
            verticalAlign: 'top',
            x:-40,
            y—80,
            floating —true,
            borderWidth: 1,
            backgroundColor: ((Highcharts.theme&&Highcharts.theme.legendBackgroundColor)|'#FFFFFF'),
            shadow —true
        },
        credits:{
            enabled —false
        },
        series: [{
            name: 'Year 1800',
            data: [107,31,635,203,2]
        }, {
            name: 'Year 1900',
            data: [133,156,947,408,6]
        }, {
            name: 'Year 2012',
            data: [1052,954,4250,740,38]
        }]
    });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>

<divid="container" style="min-width:310px;max-width:800px;height:400px;margin:0 auto"></div>


2022-09-29 22:44

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.