1
2
3
4
dataProvider = new RealGridJS.LocalDataProvider();
//pivot 객체 생성
pivot = new RealPivot("realpivot");
pivot.setDataProvider(dataProvider);
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
var fields = [{
fieldName:"국산/수입"
},{
fieldName:"국가"
},{
fieldName:"브랜드번호"
},{
fieldName:"브랜드명"
},{
fieldName:"모델번호"
},{
fieldName:"모델명"
},{
fieldName:"색상번호"
},{
fieldName:"색상"
},{
fieldName:"판매날짜",
dataType:"datetime",
datetimeFormat:"yyyy-MM-dd"
},{
fieldName:"판매수량",
dataType:"number"
},{
fieldName:"차량가격",
dataType:"number"
},{
fieldName:"차종"
},{
fieldName:"연료"
}];
dataProvider.setFields(fields);
pivot.setFieldMapping([{
name: "국가",
sourceField: "국가"
},{
name: "브랜드명",
sourceField: "브랜드명"
},{
name: "판매분기",
sourceField: "판매날짜",
dateType:"quarter",
fieldHeader:"분기",
displayFormat: "${value}사분기",
summaryFormat: "${value}사분기 합"
},{
name: "판매년도",
sourceField: "판매날짜",
dateType: "year",
fieldHeader: "년도",
displayFormat: "${value}년도",
summaryFormat: "${value}년도 합"
},{
name: "판매월",
sourceField: "판매날짜",
dateType: "month",
fieldHeader: "월",
displayFormat: "${value}월",
summaryFormat: "${value}월 합"
},{
name: "판매수량",
sourceField: "판매수량",
numberFormat:"#,##0"
},{
name: "차량가격",
sourceField: "차량가격",
numberFormat:"#,##0"
},{
name:"차종",
sourceField:"차종"
}]);
pivot.setPivotFields({
columns: ["판매분기","판매월"],
rows: ["브랜드명","차종"],
values: [{
name: "차량가격",
expression: "sum"
}, {
name: "판매수량",
expression: "sum"
}]
});
1
2
3
4
5
6
7
8
$.ajax({
url: "/resource/data/pivotDataSet.json",
success: function (data) {
dataProvider.fillJsonData(data,{count:5000});
},
complete: function(data){
}
});
1
pivot.drawView();