【发布时间】:2016-08-17 14:38:31
【问题描述】:
我正在尝试在 C3.js 的圆环图中实现同心圆弧。到目前为止,我已经创建了圆环图,现在想在圆环内添加另一个弧线,表示篮球运动员三分球命中率的百分比。
我在使用 C3.js 时找不到任何此类示例。
图表如下所示: Donut Chart
我想添加另一个 15 像素大小的弧线,并覆盖三个指针的百分比。这是我到目前为止的代码。
var chart = c3.generate({
data: {
columns: [
['Shots', 50],
['Threes', 50]
],
type: 'donut',
colors: {
Shots: '#ff0000',
Threes: '#E8E8EE'
}
},
donut: {
expand: false,
label: {
show: false,
format: function(value, ratio) {
console.log("value: " + value)
return value;
}
},
width: 15
},
legend: {
hide: true
},
tooltip: {
show: false
}
});
d3.select(".c3-chart-arcs-title")
.append("tspan")
.attr("dy", -20)
.attr("x", 0)
.text("Year: 5");
d3.select(".c3-chart-arcs-title")
.append("tspan")
.attr("dy", 16)
.attr("x", 0)
.text("50% Shots Made");
d3.select(".c3-chart-arcs-title")
.append("tspan")
.attr("dy", 16)
.attr("x", 0)
.text("25% 3ptrs Made");
【问题讨论】:
标签: javascript d3.js c3.js