amchart 연동 행 선택
RealGrid와 amchart를 사용하여 연계한 예제입니다.
그리드에서 포커스를 이동하면 선택된 행의 데이터로 차트값이 구성됩니다.
※ amchart 관련 문의는 amchart 업체에 문의를 해주시기 바랍니다.
amchart는 https://www.amcharts.com/ 페이지에서 확인 할 수 있습니다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
am4core.ready(function() {
am4core.useTheme(am4themes_animated);
var chart = am4core.create("chartdiv", am4charts.PieChart);
var pieSeries = chart.series.push(new am4charts.PieSeries());
pieSeries.dataFields.value = "litres";
pieSeries.dataFields.category = "country";
chart.innerRadius = am4core.percent(30);
pieSeries.slices.template.stroke = am4core.color("#fff");
pieSeries.slices.template.strokeWidth = 2;
pieSeries.slices.template.strokeOpacity = 1;
pieSeries.slices.template
.cursorOverStyle = [
{
"property": "cursor",
"value": "pointer"
}
];
pieSeries.alignLabels = false;
pieSeries.labels.template.bent = true;
pieSeries.labels.template.radius = 3;
pieSeries.labels.template.padding(0,0,0,0);
pieSeries.ticks.template.disabled = true;
var shadow = pieSeries.slices.template.filters.push(new am4core.DropShadowFilter);
shadow.opacity = 0;
var hoverState = pieSeries.slices.template.states.getKey("hover");
var hoverShadow = hoverState.filters.push(new am4core.DropShadowFilter);
hoverShadow.opacity = 0.7;
hoverShadow.blur = 5;
chart.legend = new am4charts.Legend();
//그리드 행 변경 이벤트
gridView.onCurrentRowChanged = function (grid, oldRow, newRow) {
var a = dataProvider.getValue(newRow, "GDP")
var b = dataProvider.getValue(newRow, "GNI")
var c = dataProvider.getValue(newRow, "PGNI")
var d = dataProvider.getValue(newRow, "DIncome")
chart.data = [{
country: "GDP",
litres: dataProvider.getValue(newRow, "GDP")
},{
country: "GNI",
litres: dataProvider.getValue(newRow, "GNI")
},{
country: "PGNI",
litres: dataProvider.getValue(newRow, "PGNI")
},{
country: "DIncome",
litres: dataProvider.getValue(newRow, "DIncome")
}]
};
});