kam*_*aci 13 javascript highcharts
我将这些值赋予Highcharts饼图:
series:[
{
type:'pie',
name:'Ratio',
data:[
['A', 42.6],
{
name:'B',
y:14.2,
sliced:true,
selected:true
}
]
}
]
Run Code Online (Sandbox Code Playgroud)
然而它在饼图中显示它:
A -> 75.00000000000001 %
B-> 25 %
Run Code Online (Sandbox Code Playgroud)
您可以在Highcharts格式化工具提示如何关于图表值?
Den*_*nis 19
plotOptions.pie.dataLabels.formatter
是一个可以让您格式化标签的功能.在这种情况下,我返回this.percentage.toFixed(2)
了将在2位小数处修剪你的数字.演示这个jsFiddle
plotOptions: {
pie: {
dataLabels: {
formatter: function() {
return '<b>' + this.point.name + '</b>: ' + this.percentage.toFixed(2) + ' %';
}
}
}
},
Run Code Online (Sandbox Code Playgroud)
小智 15
我们有工具提示格式化程序选项将值显示为数字而不是百分比
http://api.highcharts.com/highstock#tooltip.formatter
tooltip: {
formatter: function() {
return '<b>'+ this.point.name +'</b>: '+ this.point.y ;
}
},
Run Code Online (Sandbox Code Playgroud)
this.point.y会做的伎俩(现在你在那个地方有了.percentage)
小智 14
你可以像下面这样格式化它.
tooltip: {
pointFormat: "Value: {point.y:.2f}"
}
Run Code Online (Sandbox Code Playgroud)
tooltip: {
pointFormat: "Value: {point.y:.2f}"
}
Run Code Online (Sandbox Code Playgroud)
这不是为了形成价值观.
var data = [{
name: 'Population',
data: [],
dataLabels: {
enabled: true,
rotation: -90,
color: '#FFFFFF',
align: 'right',
x: 4,
y: 10,
style: {
fontSize: '13px',
fontFamily: 'Verdana, sans-serif',
textShadow: '0 0 3px black'
}, formatter: function() {
return Highcharts.numberFormat(this.y, 2, '.');
}
}
}];
Run Code Online (Sandbox Code Playgroud)
值的形式可以在数据中的dataLable中改变.
归档时间: |
|
查看次数: |
48747 次 |
最近记录: |