1
내 AngularJS와 응용 프로그램에 AmCharts을 사용하고
을 중첩 된 JSON 데이터에 액세스하고 내가 돌아올 어떤이는 JSON 데이터입니다 방법 :AmCharts
{
total: 2,
tools: [
{
id: "57c5a75d57d92f742dc96bf2",
empId: "1",
empName: "ABC",
empType: {
typeId: 3,
typeName: "Contract",
hours: 45,
}
},
{
id: "57c5a75d57d92f742dc96bf2",
empId: "2",
empName: "DEF",
empType: {
typeId: 2,
typeName: "Full-Time",
hours: 40,
}
},
]
}
코드를 내 컨트롤러 :
const writeemp = data => {
const {
total,
employees,
} = data;
empChart.dataProvider = employees;
empChart.write('emp');
empChart.validateData();
};
AmCharts.handleLoad();
var configChart = function() {
empChart = new AmCharts.AmSerialChart();
empChart.categoryField = "empId";
empChart.labelRotation = 90;
var yAxis = new AmCharts.ValueAxis();
yAxis.position = "left";
empChart.addValueAxis(yAxis);
empBarGraph = new AmCharts.AmGraph();
empBarGraph.valueField = "";//This to be the value "TypeName" in "empType" from the Json Data
empBarGraph.type = "column";
empBarGraph.fillAlphas = 1;
empBarGraph.lineColor = "#f0ab00";
empBarGraph.valueAxis = yAxis;
empChart.addGraph(empBarGraph);
empChart.write('empChart');
$http.get(hostNameService.getHostName()+"/dashboard/employees")
.then(response => writeemp(response.data));
}
수 누군가는 Amcharts에서 중첩 된 Json 데이터에 어떻게 액세스 할 수 있는지 알려주었습니다. 필자는 필드 중 하나를 차트의 valueField로 사용하려고합니다.
도움 주셔서 감사합니다. 이 경우 사용자 지정 데이터 구조를 만들었습니다. 그래, 우리는 차트의 값 필드로만 숫자를 사용할 수 있다는 것을 알고 있습니다. – Valla