javascript 无法从 chart.js 调整圆环图的大小
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27072118/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can't size doughnut chart from chart.js
提问by JJS
Not sure how to set height/width for doughnut chart, tried with this:
不知道如何设置圆环图的高度/宽度,试过这个:
<div style="height: 168px">
<canvas id="chart-area" style="height: 168px"/>
</div>
I have text underneath the chart, and this only change the position of text & graph rather than the size of the doughnut chart.
我在图表下方有文本,这只会改变文本和图形的位置,而不是圆环图的大小。
Any help will be appreciated.
任何帮助将不胜感激。
回答by Kaushik Makwana
try this in chart's option confirg
在图表的选项配置中试试这个
options = {
maintainAspectRatio : false
}
回答by Vasyl Senko
Try to set height of canvas inline:
尝试内联设置画布的高度:
<div style="height: 168px">
<canvas id="chart-area" height="168px"/>
</div>