我有以下代码从JSON数据生成基本区域图表,在图表上我希望能够显示逗号分隔数字而不是整数,即图表中的所有数字都应以逗号显示为 483,533,30 而不仅仅是48353330。
我按照各种示例中的建议添加了这个位,但似乎没有工作
$(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);
});
});
我的工作代码可以在fiddle
中看到{{1}}
答案 0 :(得分:3)
scope.$watch(
// This function returns the value being watched. It is called for each turn of the $digest loop
function() { return food; },
// This is the change listener, called when the value returned from the above function changes
function(newValue, oldValue) {
if ( newValue !== oldValue ) {
// Only increment the counter if the value changed
scope.foodCounter = scope.foodCounter + 1;
}
}
);
尝试将Highcharts.numberFormat添加到工具提示格式化程序功能中 http://api.highcharts.com/highcharts#Highcharts.numberFormat
答案 1 :(得分:0)
尝试使用X或Y:
yAxis: {
labels: {
formatter:function() {
return Highcharts.numberFormat(this.value, 0, '', ',');
}
}
}