I want to include a comma separated by digits in the value displayed on the tooltip.

Asked 2 years ago, Updated 2 years ago, 130 views

About the tooltip that appears when you hover your cursor over the graph
Please tell me how to display the displayed numbers as comma-separated values.
30,000 → 30,000

highcharts

2022-09-30 18:22

1 Answers

Set lang.thousandsSep in Highcharts.setOptions.You must also specify the format in tooltip.pointFormat.
http://api.highcharts.com/highcharts#lang.thousandsSep

Highcharts.setOptions({
    lang: {
        decimalPoint: '.',
        thousandsSep:', '
    }
});

var chart = new Highcharts.Chart({

    chart: {
        renderTo: 'container'
    },

    xAxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
    },
    
    tooltip: {
        pointFormat: "Value: {point.y:,.1f}mm"
    },

    series: [{
        data: [1029.9, 1071.5, 1106.4, 1129.2, 1144.0, 1176.0, 1135.6, 1148.5, 1216.4, 1194.1, 1095.6, 1054.4]
    }]

});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>

<divid="container" style="height:300px"></div>


2022-09-30 18:22

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.