下面的JSON可以很好地生成一个FusionCharts饼图,除了图表在渲染时显示的值不正确。在这个例子中,图表显示: 蛋白质:15.7% 脂肪:6.6% 水分:77.7% 为什么要这样做?
FusionCharts.ready(function(){
var pieChart = new FusionCharts({
"type": "pie2d",
"renderAt": "detailPiechart",
"width": "260",
"height": "260",
"dataFormat": "json",
"dataSource": {
"chart": {
"paletteColors": "#18a4a4,#ffa365,#c0c0c0",
"theme": "fint",
"startingAngle": "325",
"bgColor": "#ffffff",
"baseFontSize": "12",
"pieRadius": "75",
"labelFontSize": "12",
"labelDistance": "1",
"showBorder": "0",
"showValues": "1",
"animation": "0",
"showLabels": "0",
"use3DLighting": "1",
"showShadow": "0",
"enableSmartLabels": "0",
"startingAngle": "0",
"showPercentValues": "1",
"showPercentInTooltip": "1",
"decimals": "1",
"captionFontSize": "14",
"subcaptionFontSize": "14",
"subcaptionFontBold": "0",
"toolTipColor": "#ffffff",
"toolTipBorderThickness": "0",
"toolTipBgColor": "#000000",
"toolTipBgAlpha": "80",
"toolTipBorderRadius": "2",
"toolTipPadding": "5",
"showHoverEffect": "1",
"showLegend": "1",
"legendBgColor": "#ffffff",
"legendBorderAlpha": "0",
"legendShadow": "0",
"legendItemFontSize": "12",
"legendItemFontColor": "#666666",
"useDataPlotColorForLabels": "1"
},
"data": [
{
"label": "Protein",
"value": "15.3"
},
{
"label": "Fat",
"value": "6.4"
},
{
"label": "Moisture",
"value": "75.8"
}
]
}
});
pieChart.render();
})
答案 0 :(得分:1)
由于属性" showPercentValues":" 1"在图表级别设置,因此显示的值以百分比表示。请参阅:http://bit.ly/1mWHvM1