我正在尝试更改融合图表划分的高度和宽度,但同时也会降低图表的高度和宽度。
代码:
<div class="col-lg-4">
<div class="modal-body padding0" style="min-height:300px;">
<fusioncharts width= '300' height= '150' type="doughnut2d" [dataSource]="dataSpurceUserExp"> </fusioncharts>
</div>
</div>
<div class="col-lg-4">
<div class="modal-body padding0" style="min-height:300px;">
<fusioncharts width= '300' height= '150' type="doughnut2d" [dataSource]="dataSpurceUserExp"> </fusioncharts>
</div>
</div>
查看所附图片。
答案 0 :(得分:2)
FusionCharts甜甜圈图调整其内部和外部甜甜圈半径,以及图例,标签,值等各种组件,以适应提供给图表高度和宽度的尺寸。
因此,甜甜圈半径将根据图表上的可用空间而随图表尺寸的变化而变化。
有一个选项可以按百分比提供图表尺寸,在这种情况下,必须为容器div提供以像素为单位的高度/宽度或动态提供(可能使用Bootstrap)。
因此,当使用Bootstrap动态设置div尺寸并且以百分比形式设置图表尺寸时,甜甜圈半径会随着图表尺寸的变化而动态更改。
请参阅示例小提琴:https://jsfiddle.net/kv8npm1w/
FusionCharts.ready(function() {
var revenueChart = new FusionCharts({
type: 'doughnut2d',
renderAt: 'chart-container1',
width: '100%',
height: '350',
dataFormat: 'json',
dataSource: {
"chart": {
"caption": "Split of Revenue by Product Categories",
"subCaption": "Last year",
"legendPosition": "RIGHT",
"showLegend": "1",
"showLabels": "0",
"showValues": "0",
"numberPrefix": "$",
"startingAngle": "310",
"showTooltip": "0",
"decimals": "0",
"pieRadius": "80",
"doughnutRaius": "60"
},
"data": [{
"label": "Work place services",
"value": "28504"
}]
}
}).render();
var revenueChart = new FusionCharts({
type: 'doughnut2d',
renderAt: 'chart-container2',
width: '100%',
height: '350',
dataFormat: 'json',
dataSource: {
"chart": {
"caption": "Split of Revenue by Product Categories",
"subCaption": "Last year",
"legendPosition": "RIGHT",
"showLegend": "1",
"showLabels": "0",
"showValues": "0",
"numberPrefix": "$",
"startingAngle": "310",
"showTooltip": "0",
"decimals": "0"
},
"data": [{
"label": "Work place services",
"value": "28504"
}]
}
}).render();
var revenueChart = new FusionCharts({
type: 'doughnut2d',
renderAt: 'chart-container3',
width: '100%',
height: '350',
dataFormat: 'json',
dataSource: {
"chart": {
"caption": "Split of Revenue by Product Categories",
"subCaption": "Last year",
"legendPosition": "RIGHT",
"showLegend": "1",
"showLabels": "0",
"showValues": "0",
"numberPrefix": "$",
"startingAngle": "310",
"showTooltip": "0",
"decimals": "0"
},
"data": [{
"label": "Work place services",
"value": "28504"
}]
}
}).render();
});
此外,在图表数据源中还可以使用“ doughnutRadius”和“ pieRadius”显式设置内半径和外半径。
但是请注意,显式设置半径可能会导致重叠或圆环超出图表尺寸,因为自从显式设置以来,它现在不会调整其半径。
样本小提琴(已明确设置半径的第一个图表):https://jsfiddle.net/kv8npm1w/2/
{{1}}