Sun*_*gia 9 javascript php charts c3.js
如何更改饼图图例的文本.我在我的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
});
Run Code Online (Sandbox Code Playgroud)
它没有显示我的传奇值,它总是只显示列作为图例.
有什么方法可以更改图例值.
Sea*_*ean 14
你还没有提供从php输出的数据,所以很难说.
但是每个列数组中的第一项确定了图例中的名称.所以:
columns: [
['this is legend 1', 30],
['put your value here', 120],
]
Run Code Online (Sandbox Code Playgroud)
会导致图例标签为"这是传说1"并且"把你的价值放在这里".
这是一个小提琴:http: //jsfiddle.net/jrdsxvys/9/
编辑...另一种选择是使用names属性,如下所示:http: //jsfiddle.net/jrdsxvys/40/
data: {
columns: [
['d1', 30],
['d2', 120]
],
type: 'pie',
labels: true,
names: {
d1: 'some name here',
d2: 'another name'
}
}
Run Code Online (Sandbox Code Playgroud)