如何更改饼图图例的文本。我在我的 php 页面中使用 c3 图表。我已经阅读了 c3 图表的文档,但没有运气。
目前我正在使用这段代码,它显示图例true
但我无法更改我尝试过的文本。
var chart = c3.generate({
bindto: '#container',
padding: {
top: 10,
right: 0,
bottom: 10,
left: 0,
},
data: {
columns: [<?php echo $pieChartDataString; ?>],
type : 'pie',
labels: true
},
legend: {
show: true,
position: 'upper-center'
format: {
title: function () { return "Legend title"; },
name : function () { return "Legend name"; },
value: function () { return "Legend value";}
}
}
//But these legend values or not showing
});
它没有显示我的图例值,它始终只显示列作为图例。
有什么方法可以改变图例值。
你还没有提供从你的 php 输出的数据,所以很难说。
但每个列数组中的第一项决定图例中的名称。所以:
columns: [
['this is legend 1', 30],
['put your value here', 120],
]
将导致图例标签为“这是图例 1”和“将您的值放在这里”。
这是一个小提琴:http://jsfiddle.net/jrdsxvys/9/ http://jsfiddle.net/jrdsxvys/9/
编辑...
另一种选择是使用名称属性,如下所示:http://jsfiddle.net/jrdsxvys/40/ http://jsfiddle.net/jrdsxvys/40/
data: {
columns: [
['d1', 30],
['d2', 120]
],
type: 'pie',
labels: true,
names: {
d1: 'some name here',
d2: 'another name'
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)