안녕하세요. Angularjs 응용 프로그램에서 차트를 구현하고 있습니다.이 플 런커를 볼 수 있습니다. http://jsfiddle.net/fusioncharts/73xgmacm/
달성하고자하는 것은 value
속성을 profit
으로 변경하는 것입니다. 어떻게해야합니까? profit
값을 표시하고 싶습니다.Fusionchart의 데이터 세트에서 속성을 변경하려면 어떻게해야합니까?
감사합니다.
안녕하세요. Angularjs 응용 프로그램에서 차트를 구현하고 있습니다.이 플 런커를 볼 수 있습니다. http://jsfiddle.net/fusioncharts/73xgmacm/
달성하고자하는 것은 value
속성을 profit
으로 변경하는 것입니다. 어떻게해야합니까? profit
값을 표시하고 싶습니다.Fusionchart의 데이터 세트에서 속성을 변경하려면 어떻게해야합니까?
감사합니다.
2 일 후에 나는 결국 대답을 찾습니다. 문제는 Fusionchart
속성 value
을 변경할 수 없지만 가져온 API의 속성을 변경할 수 있다는 것입니다. API를 가져 와서 'profit'속성을 value
으로 대체 한 후 루프를 사용했습니다.이 방식으로 차트를 만들었습니다. 예 내가 무시했던 것은 범위 대신 '변수'를 사용하는 것입니다. 이 예를 보면 Example Here을 이해할 수 있습니다. 내 코드를 공유하고 있습니다. 다른 사람에게도 도움이 될 수 있습니다.
아래 줘 내가 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();
});
}
);
}
자세를 낮춰 어리석은 숙박 배고픈
내 컨트롤러라고 내 JSON 배열입니다