【发布时间】:2017-03-23 13:21:22
【问题描述】:
我正在显示极坐标图。但是如何在饼图中显示标签,如下面的屏幕
这是我的代码: Code
<canvas id="myChart"></canvas>
<script>
var ctx = document.getElementById("myChart").getContext('2d');
var myChart = new Chart(ctx, {
type: 'polarArea',
data: {
labels: ["Harmonia wewnetrzna", "Relacje towarzyskie", "Relacje damsko-meskie", "Finanse", "Zdrowie", "Hobby i czas wolny"],
datasets: [{
backgroundColor: [
"rgba(46, 204, 113, 0.7)",
"rgba(52, 152, 219, 0.7)",
"rgba(149, 165, 166, 0.7)",
"rgba(155, 89, 182, 0.7)",
"rgba(241, 196, 15, 0.7)",
"rgba(231, 76, 60, 0.7)"
],
data: [50, 70, 20, 45, 90, 70],
pointBackgroundColor: "rgba(255,99,132,1)",
pointBorderColor: "red",
pointHoverBackgroundColor: "#fff",
pointHoverBorderColor: "rgba(255,99,132,1)"
}]
},
options:{
legend: {
display: true,
position: 'bottom'
},
animation : false,
scale:{
lineArc: true,
angleLines: {
color: "rgba(204, 255, 51, 0.5)"
},
pointLabels: {
fontColor: "ff6666"
},
gridLines : {
color : "pink"
},
ticks: {
min: 0,
max: 100
}
}
}
});
</script>
【问题讨论】:
-
请在此问题中添加您的代码,以便如果人们有与您相同的问题,他们可以立即看到代码,谢谢。
-
这个问题也出现在饼图中并且仍然存在github.com/chartjs/Chart.js/issues/3289
标签: javascript canvas chart.js