您好我在Angularjs应用程序中实现了一个图表,您可以看到这个plunker http://jsfiddle.net/fusioncharts/73xgmacm/
我想要实现的是将value
属性更改为profit
。我怎样才能做到这一点 ?我想显示profit
而不是值。
此致
答案 0 :(得分:0)
2天后我终于找到了答案。问题是您无法更改Fusionchart
属性value
,但您可以在获取后更改API的属性。在我获取API并使用value
替换'profit'属性后,我使用了一个循环,这样我制作了图表。是的,我忽略的是使用'变量'而不是范围。如果你看到这个例子,你会理解Example Here。我正在分享我的代码也许它可以帮助其他人。
下面是我的json数组,我称之为tps.json
[
{
"index": "1",
"variantoption": "fan-green",
"company": "sk fans",
"quantity": "650",
"profit": "78296",
"loss": "8457",
"year": "2016"
},
{
"index": "2",
"variantoption": "fan-white",
"company": "al ahmed fans",
"quantity": "450",
"profit": "78296",
"loss": "8457",
"year": "2016"
},
{
"index": "3",
"variantoption": "fan-purple",
"company": "asia fans",
"quantity": "350",
"profit": "78296",
"loss": "8457",
"year": "2016"
},
{
"index": "4",
"variantoption": "fan-yellow",
"company": "falcon fans",
"quantity": "250",
"profit": "78296",
"loss": "8457",
"year": "2016"
}
]
这是我的控制器
$http.get('js/tps.json').success(function (data) {
var chartdata = data;
var arrLength = chartdata.length;
console.log(arrLength);
for (var i = 0; i < arrLength; i++) {
if (chartdata[i]['profit'] && chartdata[i]['index']) {
chartdata[i].value = chartdata[i].profit;
delete chartdata[i].profit;
chartdata[i].label = chartdata[i].index;
delete chartdata[i].index;
console.log(chartdata);
}
}
console.log(chartdata);
FusionCharts.ready(function () {
var tps = new FusionCharts({
type: 'column2d',
renderAt: 'chart-container',
width: '500',
height: '300',
dataFormat: 'json',
dataSource: {
"chart": {
"caption": "Monthly",
"xaxisname": "Month",
"yaxisname": "Revenue",
"numberprefix": "$",
"showvalues": "1",
"animation": "1"
},
"data" : chartdata
}
});
tps.render();
});
}
);
}
- 愚蠢的保持饥饿