Warm tip: This article is reproduced from stackoverflow.com, please click
highcharts javascript vue.js

highcharts round generated y labels in 1024 multiply not 1000

发布于 2020-04-13 10:12:31

I have a chart with sample data: [1462218035, 2079623792, 2146097338, 2169087177] and in y axis label i convert it to human readable bytes:

yAxis: {
    labels: {
    useHTML: true,
    formatter: function () {
        return bytesToReadable(this.value, true);
    },
  },
}

bytesToReadable converts bytes to human readable data: 1,36 GB - 1,94 GB - 2 GB and it shows y labels like: 953,67 MB - 1,86 GB - 2,79 GB those are 2,000,000,000 - 4,000,000,000 - 6,000,000,000 converted by bytesToReadable. What i want is 2,000,000,000 - 4,000,000,000 - 6,000,000,000 generated by highcharts to be multiply of 1024 to be correct numbers after convert like 100 MB - 1GB - 4GB.

Questioner
Fateme Fazli
Viewed
53
ppotaczek 2020-02-06 17:59

Use tickInterval property:

yAxis: {
  tickInterval: 1024
}

Live demo: http://jsfiddle.net/BlackLabel/6m4e8x0y/4806/

API Reference: https://api.highcharts.com/gantt/yAxis.tickInterval