-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
154 lines (149 loc) · 4.08 KB
/
index.html
File metadata and controls
154 lines (149 loc) · 4.08 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<!DOCTYPE html>
<html lang="en">
<head>
<title>Essential JS 2 Pivot Table</title>
<script
src="https://cdn.syncfusion.com/ej2/26.2.4/dist/ej2.min.js"
type="text/javascript"
></script>
<link
href="https://cdn.syncfusion.com/ej2/26.2.4/material.css"
rel="stylesheet"
/>
<style>
#performanceTime {
margin-left: 20px;
}
</style>
</head>
<body>
<h2>Syncfusion JavaScript (ES5) Pivot Table Control</h2>
<div class="control-section">
<div id="btn-control" style="margin-bottom: 5px">
<button id="btn1" style="margin-right: 20px">Load 100K Data</button>
<button id="btn2">Load 1 Million Data</button>
<span id="performanceTime"><b>Time Taken:</b> 0 sec</span>
</div>
<div class="content-wrapper">
<div id="PivotTable" style="height: 100%"></div>
</div>
</div>
<script>
var customername = [
"TOM",
"Hawk",
"Jon",
"Chandler",
"Monica",
"Rachel",
"Phoebe",
"Gunther",
"Ross",
"Geller",
"Joey",
"Bing",
"Tribbiani",
"Janice",
"Bong",
"Perk",
"Green",
"Ken",
"Adams",
];
var city = [
"New York",
"Los Angeles",
"Chicago",
"Houston",
"Philadelphia",
"Phoenix",
"San Antonio",
"Austin",
"San Francisco",
"Columbus",
"Washington",
"Portland",
"Oklahoma",
"Las Vegas",
"Virginia",
"St. Louis",
"Birmingham",
];
var date1;
var date2;
var isInit;
var dt = 0;
var data = function (count) {
var result = [];
for (var i = 1; i < count + 1; i++) {
dt++;
var value = count + i;
result.push({
ProductID: "PRO-" + value,
City: city[Math.round(Math.random() * city.length)] || city[0],
Year: "FY " + (dt + 2013),
CustomerName:
customername[Math.round(Math.random() * customername.length)] ||
customername[0],
Price: Math.round(Math.random() * 5000) + 5000,
Sold: Math.round(Math.random() * 80) + 10,
});
if (dt / 4 == 1) {
dt = 0;
}
}
return result;
};
var pivotObj = new ej.pivotview.PivotView({
dataSourceSettings: {
dataSource: [],
enableSorting: false,
expandAll: true,
rows: [{ name: "ProductID" }],
columns: [{ name: "Year" }],
values: [
{ name: "Price", caption: "Unit Price" },
{ name: "Sold", caption: "Unit Sold" },
],
},
width: "100%",
height: 300,
enableVirtualization: true,
dataBound: function () {
if (this.dataSourceSettings.dataSource.length > 0) {
if (date1 && isInit) {
date2 = new Date().getTime();
document.getElementById("performanceTime").innerHTML =
"<b>Time Taken:</b> " + (date2 - date1) / 1000 + " sec";
}
isInit = false;
}
if (ej.base.Browser.isDevice && pivotObj && pivotObj.enableRtl) {
document.querySelector(".control-section").classList.add("e-rtl");
}
},
});
pivotObj.appendTo("#PivotTable");
var button1 = new ej.buttons.Button({
isPrimary: true,
cssClass: "e-info",
});
button1.appendTo("#btn1");
var button2 = new ej.buttons.Button({
isPrimary: true,
cssClass: "e-info",
});
button2.appendTo("#btn2");
button1.element.onclick = function () {
isInit = true;
pivotObj.dataSourceSettings.dataSource = data(100000);
date1 = new Date().getTime();
};
button2.element.onclick = function () {
isInit = true;
pivotObj.dataSourceSettings.dataSource = data(1000000);
date1 = new Date().getTime();
};
</script>
</body>
</html>