Reputation: 13468
I Have the following code which generates a basic area chart from JSON data, on the chart i want to be able to show comma separated numbers instead of a whole integer ie all the number in the chart should show with a comma as 483,533,30 instead of just 48353330.
I added this bit as suggested in various examples but doesn't seem to be working
Highcharts.setOptions({
lang: {
thousandsSep: ','
}
});
My working code can be seen here in fiddle
$(document).ready(function() {
Highcharts.setOptions({
lang: {
thousandsSep: ','
}
});
var options = {
chart: {
renderTo: 'container',
type: 'area',
marginRight: 130,
marginBottom: 25
},
title: {
text: 'Deposit Institution',
x: -20 //center
},
subtitle: {
text: '',
x: -20
},
xAxis: {
categories: []
},
yAxis: {
title: {
text: 'Amount'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+
this.x +': $'+ this.y;
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -10,
y: 100,
borderWidth: 0
},
series: []
}
$.getJSON("data1.json", function(json) {
options.xAxis.categories = json[0]['data'];
options.series[0] = json[1];
options.series[1] = json[2];
chart = new Highcharts.Chart(options);
});
});
Upvotes: 1
Views: 1263
Reputation: 46
tooltip: {
formatter: function() {
return '<b>' + this.series.name + '</b><br/>' +
this.x + ': $' + Highcharts.numberFormat(this.y, 0, '', ',');
}
}
Try adding Highcharts.numberFormat to your tooltip formatter function http://api.highcharts.com/highcharts#Highcharts.numberFormat
Upvotes: 3
Reputation: 797
Try this with X or with Y:
yAxis: {
labels: {
formatter:function() {
return Highcharts.numberFormat(this.value, 0, '', ',');
}
}
}
Upvotes: 0