This project is read-only.

Custom string format of DotNet.Highcharts Data Series label

Aug 20, 2014 at 1:55 PM
I would like to format text of Data Series labels which is indicating the values in DotNet Highcharts.
for examle a bar chart whit X axis as a dateTime and Y axis as a traffic volume. now i want to show value points in lable like this: 2GB,124MB,245KB.
but i cant find where i can call my custom function in order to format the label text as above.
i'm really appreciated if you could help me on this.
Oct 24, 2014 at 3:54 PM

You can use the JavaScript function stackoverflow:
function bytesToSize(bytes) {
   if(bytes == 0) return '0 Byte';
   var k = 1000;
   var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
   var i = Math.floor(Math.log(bytes) / Math.log(k));
   return (bytes / Math.pow(k, i)).toPrecision(3) + ' ' + sizes[i];
And you can call it from the formattеr of yAxis lable:
                    new YAxis
                        Labels = new YAxisLabels
                            Formatter = "function() { return bytesToSize(this.value); }",
Is this helps you?