charts.js分层甜甜圈饼图
charts.js layered donut pie chart
我正在尝试使用chart.js制作一个分层的圆环图。我已经用了两层,但我不明白为什么第三层没有显示。
为什么第三个甜甜圈没有显示?
感谢您的帮助
<div id="w">
<canvas id="d1" height="600" width="600"></canvas>
<canvas id="d2" height="500" width="500"></canvas>
<canvas id="d3" height="400" width="400" ></canvas>
#w {
position: relative;
height: 600px;
width: 600px;
}
#d1, #d2, #d3 {
position: absolute;
}
#d3 {
position: absolute;
}
#d1 {
top: 0px;
left: 0px;
}
#d2 {
top: 8%;
left: 8%;
}
#d3 {
top: 11%;
left: 11%;
}
var doughnutData = [
{
value: 20,
color:"#F7464A",
highlight: "#FF5A5E",
label: "Red",
},
{
value: 50,
color: "#46BFBD",
highlight: "#5AD3D1",
label: "Green"
},
{
value: 30,
color: "#FDB45C",
highlight: "#FFC870",
label: "Yellow"
},
{
value: 40,
color: "#949FB1",
highlight: "#A8B3C5",
label: "Grey"
},
{
value: 120,
color: "#4D5360",
highlight: "#616774",
label: "Dark Grey"
}
];
var doughnutData2 = [
{
value: 10,
color:"#F7464A",
highlight: "#FF5A5E",
label: "Red",
},
{
value: 100,
color: "#46BFBD",
highlight: "#5AD3D1",
label: "Green"
},
{
value: 20,
color: "#FDB45C",
highlight: "#FFC870",
label: "Yellow"
},
{
value: 60,
color: "#949FB1",
highlight: "#A8B3C5",
label: "Grey"
},
{
value: 120,
color: "#4D5360",
highlight: "#616774",
label: "Dark Grey"
}
];
var doughnutData3 = [
{
value: 20,
color:"#F7464A",
highlight: "#FF5A5E",
label: "Red",
},
{
value: 90,
color: "#46BFBD",
highlight: "#5AD3D1",
label: "Green"
},
{
value: 20,
color: "#FDB45C",
highlight: "#FFC870",
label: "Yellow"
},
{
value: 60,
color: "#949FB1",
highlight: "#A8B3C5",
label: "Grey"
},
{
value: 120,
color: "#4D5360",
highlight: "#616774",
label: "Dark Grey"
}
];
var ctx1 = $("#d1").get(0).getContext("2d");
var myChart1 = new Chart(ctx1).Doughnut(doughnutData, {
percentageInnerCutout: 90
});
var ctx2 = $("#d2").get(0).getContext("2d");
var myChart2 = new Chart(ctx2).Doughnut(doughnutData2, {
percentageInnerCutout: 90
});
var ctx3 = $("#d3").get(0).getContext("3d");
var myChart3 = new Chart(ctx3).Doughnut(doughnutData3, {
percentageInnerCutout: 90
});
请参阅此处了解CodePen
您请求的是3d上下文,而不是最后一个图表中的2d上下文。所以改变这个
var ctx3 = $("#d3").get(0).getContext("3d");
var myChart3 = new Chart(ctx3).Doughnut(doughnutData3, {
percentageInnerCutout: 90
});
到这个
var ctx3 = $("#d3").get(0).getContext("2d");
var myChart3 = new Chart(ctx3).Doughnut(doughnutData3, {
percentageInnerCutout: 90
});
相关文章:
- 在Javascript甜甜圈图的PHP变量中引用PHP变量
- 装订莫里斯甜甜圈图
- Highcharts甜甜圈工具提示格式使用钻取数据
- D3将两张甜甜圈图叠加在一起
- 如何使高图表半甜甜圈出现在角度应用中
- 莫里斯.js甜甜圈标签不在中间的jquery标签中
- 强制 ChartJS 显示具有空值的甜甜圈图
- 无法从图表.js调整甜甜圈图的大小
- GWT Highcharts-半圆甜甜圈
- d3.js甜甜圈图::其他路径被渲染而不更新
- Morris甜甜圈图的设置数据
- 甜甜圈饼图NVD3
- 饼(甜甜圈)图分段顺序在D3
- 在morris.js中触发甜甜圈片段的点击事件
- angular (1.5) nvd3嵌套甜甜圈
- 甜甜圈图d3.js
- 图表js -填充甜甜圈
- D3甜甜圈图表图例或标签悬停
- HIghcharts甜甜圈图没有所有的切片
- charts.js分层甜甜圈饼图