我生成图形。[link] http://jsfiddle.net/sunman/XRr8M/2/。我想要显示我的总叠加值是1 / 10,2 / 10,5 / 10这样在列顶部。但我正在尝试这个。这个代码没有显示像1 / 10,2 / 10,它显示0.00 / 10这样。如何在列顶部显示我的总叠加值/ 10。所以请给我建议。
这是我的代码
$(document).ready(function () {
var options = {
chart: {
renderTo: 'container',
type: 'column',
marginRight: 130,
marginBottom: 50
},
title: {
text: 'Top Rating',
x: -20 //center
},
subtitle: {
text: 'testing',
x: -20
},
xAxis: {
categories: []
},
yAxis: {
title: {
text: 'monthly Rating'
},
stackLabels: {
enabled: true,
formatter:function(){
// return '<b>' + this.series.name + '</b><br/>' + this.x + ': ' + this.y +'/10'
return Highcharts.numberFormat(this.y) + '/10'
},
style: {
fontWeight: 'bold',
color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
}
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
formatter: function () {
return '<b>' + this.series.name + '</b><br/>' + this.x + ': ' + this.y;
}
},
plotOptions:{
dataLabels: {
enabled: true,
},
column: {
stacking: 'normal',
dataLabels: {
enabled: true,
color:'white',
}
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
borderWidth: 0
},
series: [{
name: 'RATING',
data: [],
id: 'dataseries'
}, {
type: 'flags',
onSeries: 'dataseries',
data: [{
x: 0,
text: 'Minimum Facilites Rating',
title: 'Min'
}, {
x: 10,
text: 'Maximum Facilites Rating',
title: 'max'
}],
width: 30,
showInLegend: false
}]
};
//imitate AJAX:
json = [{
data: ['a', 'b', 'c','d','e', 'f', 'g','h','i', 'j', 'k','l']
}, {
data: [1, 2, 3, 1, 2, 3, 4, 1, 3, 3, 3, 3, 3, 3, 5, 1]
}];
options.xAxis.categories = json[0]['data'];
options.series[0].data = json[1]['data'];
chart = new Highcharts.Chart(options);
});
所以请你们所有人告诉我这是怎么可能的。
答案 0 :(得分:0)
你应该在格式化程序中使用this.total not this.y。
return Highcharts.numberFormat(this.total) + '/10'