[英]Controlling Morris Donut Chart dimesnions i.e. Height & width
我正在使用莫里斯图绘制甜甜圈图。 但我想控制它的高度。 甜甜圈图始终具有固定大小。 当我降低div的高度时,它不尊重div的尺寸。甜甜圈图溢出。
<html>
<head>
#donutChart{
height:200px;
}
</head>
<body>
<div id="donutChart"></div>
</body>
<script>
var donutData = [{label:"A", count:100},
{label:"B", count:200},
{label:"C", count:300}
]
var color: [ "red", "green", "blue"]
drawDonutChart( divId, donutData, colors ){
var total = 0;
for(var i = 0; i < donutData.length ; i++){
var item = donutData[i];
total += item.value
}
Morris.Donut({
element: divId,
data: donutData,
colors: colors,
formatter: function(x) {
return Math.round( (x*100)/total ) +"% ("+ x +")" ;
}
});
}
</script>
<html>
您可以在morris.js中设置它Donut.prototype.redraw = function()
请检查以下Donut.prototype.redraw = function()
行:
cx = this.el.width() / 2;
cy = this.el.height() / 2;
也不要忘记设置父dom元素的尺寸。 希望这可以帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.