我想让我的 fusionchart 饼图响应迅速,所以我遵循这里的一些指南: http://docs.fusioncharts.com/charts/contents/FirstChart/ChangeSize.html 我按照“图表的动态调整大小功能”部分中的说明进行操作。
但是当页面加载时,我的图表变平了(没有高度)。
当我调整浏览器大小时,图表大小响应成功,但我得到一个非常小的饼图
为什么我的图表在页面首次加载时变平了? (我必须先调整浏览器大小才能看到图表)。为什么我得到一个非常小的图表?
这是我的代码
<body style="height:100%;">
<div class="container-fluid">
<div class="row-fluid">
<div class="col-md-12">
<div id="chartContainer" style="height:100%;">
FusionCharts XT will load here!
</div>
</div>
</div>
</div>
<script type="text/javascript">
FusionCharts.ready(function(){
var myChart = new FusionCharts({
"type": "pie2d",
"dataFormat": "jsonurl",
"dataSource": "pie.json",
"width": "100%",
"height": "100%"
});
myChart.render("chartContainer");
});
</script>
这是我的 pie.json :
{
"chart":{
"caption":"Rasio Pendapatan Aeronautika & Non-Aeronautika",
"subCaption":"Januari-Juni 2014",
"paletteColors":"#008ee4,#6baa01,#f8bd19,#e44a00,#33bdda",
"bgAlpha":"0",
"borderAlpha":"20",
"use3DLighting":"0",
"showShadow":"0",
"enableSmartLabels":"0",
"startingAngle":"0",
"showPercentValues":"1",
"showPercentInTooltip":"0",
"decimals":"3"},
"data":
[
{
"label":"Non-Aeronautika",
"value":"534.973.345.227\r",
"link":"newchart-jsonurl-naero.json"
},
{
"label":"Aeronautika",
"value":"960.429.586.179\r",
"link":"newchart-jsonurl-aero.json"
}
]
你能指出我的错误吗?
感谢您的关注,我们将不胜感激..
最佳答案
使用 AngularJS 和 Bootstrap。
在我的 HTML 中,我将 width="300"更改为 width="100%" 这使我的圆环图响应迅速:
HTML:
<div class="row" data-ng-controller="VariableInvestmentSummaryCtrl">
<div class="col-md-4">
<div fusioncharts
width="100%"
height="300"
type="doughnut2d"
dataSource="{{myDataSource}}" >
</div>
</div>
<div class="col-md-8 datagrid-wrapper investments"></div>
</div>
JSON:
$scope.myDataSource = {
'chart': {
'numberPrefix': '%',
'theme': 'fint',
'bgColor': '#DDDDDD',
'bgAlpha': '0'
},
'data':[{
'showLabel': '0',
'label': 'Some Name',
'showValue': '0',
'value': '25'
},
{
'showLabel': '0',
'label': 'Garden Groove harbour',
'showValue': '0',
'value': '50'
},
{
'showLabel': '0',
'label': 'Los Angeles Topanga',
'showValue': '0',
'value': '10'
},
{
'showLabel': '0',
'label': 'Compton-Rancho Dom',
'showValue': '0',
'value': '10'
},
{
'showLabel': '0',
'label': 'Daly City Serramonte',
'showValue': '0',
'value': '5',
'color': '#FE0000'
}]
};
关于javascript - 带有融合图的响应式饼图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24422016/