如何从Chart.js饼图中删除白色边框? [英] How can I remove the white border from Chart.js pie chart?
本文介绍了如何从Chart.js饼图中删除白色边框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Chart.js饼图,我想删除切片之间的白线。有人能告诉我这样做吗?提前致谢
I am using Chart.js pie chart and I'd like to remove white lines between slices. Could someone tell me way to do this ? Thanks in advance
我在文档中没有看到任何内容。
I didn't see anything in the documenation.
<div class="pie-chart">
<div id="canvas-holder">
<canvas id="chart-area" width="250" height="250"/>
</div>
</div>
推荐答案
更新
对于较新版本的Chart.js(即2.2.2及更高版本),请参阅 @ grebenyuksv的回答。
For newer versions of Chart.js (i.e. 2.2.2 and higher), see @grebenyuksv's answer.
这个答案是为旧版本的Chart.js添加的(即1.0.2)
This answer was added for an older version of Chart.js (i.e. 1.0.2)
原始答案
只需配置图表的选项即可隐藏line
Just configure the options for the chart to hide the line
segmentShowStroke:false
像这样的东西:
//create chart
var ctx = document.getElementById("myChart").getContext("2d");
var data = [{
value: 300,
color: "#F7464A",
highlight: "#FF5A5E",
label: "Red"
}, {
value: 50,
color: "#46BFBD",
highlight: "#5AD3D1",
label: "Green"
}, {
value: 100,
color: "#FDB45C",
highlight: "#FFC870",
label: "Yellow"
}];
var options = {
//Boolean - Whether we should show a stroke on each segment
// set to false to hide the space/line between segments
segmentShowStroke: false
};
// For a pie chart
var myPieChart = new Chart(ctx).Pie(data, options);
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.js"></script>
<canvas id="myChart" width="200" height="200"></canvas>
这篇关于如何从Chart.js饼图中删除白色边框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文