This repository was archived by the owner on Jul 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathspark-grid.js
More file actions
159 lines (159 loc) · 7.45 KB
/
spark-grid.js
File metadata and controls
159 lines (159 loc) · 7.45 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
155
156
157
158
159
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Sample for sparkline in grid
*/
var React = require("react");
var ej2_base_1 = require("@syncfusion/ej2-base");
var ej2_react_charts_1 = require("@syncfusion/ej2-react-charts");
var ej2_react_grids_1 = require("@syncfusion/ej2-react-grids");
var data_source_1 = require("./data-source");
var sample_base_1 = require("../common/sample-base");
ej2_base_1.enableRipple(true);
var SAMPLE_CSS = "\n .control-fluid {\n\t\tpadding: 0px !important;\n }";
var GridData = (function () {
function GridData() {
}
return GridData;
}());
exports.GridData = GridData;
var SparkGrid = (function (_super) {
__extends(SparkGrid, _super);
function SparkGrid() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.lineData = [
[0, 6, 4, 1, 3, 2, 5],
[5, 4, 6, 3, 1, 2, 0],
[6, 4, 0, 3, 2, 5, 1],
[4, 6, 3, 0, 1, 2, 5],
[3, 5, 6, 4, 0, 1, 2],
[1, 3, 4, 2, 5, 0, 6],
[2, 4, 0, 3, 5, 6, 1],
[5, 4, 6, 3, 1, 2, 0],
[0, 6, 4, 1, 3, 2, 5],
[6, 4, 0, 3, 2, 5, 1],
[4, 6, 3, 0, 1, 2, 5],
[3, 5, 6, 4, 0, 1, 2],
[1, 3, 4, 2, 5, 0, 6],
[2, 4, 0, 3, 5, 6, 1],
[5, 4, 6, 3, 1, 2, 0],
[0, 6, 4, 1, 3, 2, 5],
[6, 4, 0, 3, 2, 5, 1],
[4, 6, 3, 0, 1, 2, 5],
[2, 4, 0, 3, 5, 6, 1],
[3, 5, 6, 4, 0, 1, 2],
[1, 3, 4, 2, 5, 0, 6]
];
_this.columnData = [
[0, 6, -4, 1, -3, 2, 5],
[5, -4, 6, 3, -1, 2, 0],
[6, 4, 0, 3, -2, 5, 1],
[4, -6, 3, 0, 1, -2, 5],
[3, 5, -6, -4, 0, 1, 2],
[1, -3, 4, -2, 5, 0, 6],
[2, 4, 0, -3, 5, -6, 1],
[5, 4, -6, 3, 1, -2, 0],
[0, -6, 4, 1, -3, 2, 5],
[6, 4, 0, -3, 2, -5, 1],
[4, 6, -3, 0, 1, 2, 5],
[3, -5, -6, 4, 0, 1, 2],
[1, 3, -4, -2, 5, 0, 6],
[2, -4, 0, -3, 5, 6, 1],
[5, 4, -6, 3, 1, -2, 0],
[0, 6, 4, -1, -3, 2, 5],
[6, -4, 0, -3, 2, 5, 1],
[4, 6, -3, 0, -1, 2, 5],
[6, 4, 0, -3, 2, -5, 1],
[3, 5, 6, -4, 0, 1, 2],
[1, 3, -4, 2, -5, 0, 6]
];
_this.getSparkData = function (type, count) {
if (type === 'line') {
return _this.lineData[count];
}
else {
return _this.columnData[count];
}
};
return _this;
}
SparkGrid.prototype.load = function (args) {
var theme = location.hash.split('/')[1];
theme = theme ? theme : 'Material';
args.sparkline.theme = (theme.charAt(0).toUpperCase() + theme.slice(1));
};
SparkGrid.prototype.renderSparkline = function () {
var _this = this;
setTimeout(function () {
for (var i = 1; i < 21; i++) {
var line = new ej2_react_charts_1.SparklineComponent({
height: '50px',
width: '150px',
lineWidth: 2,
valueType: 'Numeric',
fill: '#3C78EF',
dataSource: _this.getSparkData('line', i)
});
line.appendTo('#spkline' + i);
var column = new ej2_react_charts_1.SparklineComponent({
height: '50px',
width: '150px',
type: 'Column',
valueType: 'Numeric',
fill: '#3C78EF',
negativePointColor: '#f7a816',
dataSource: _this.getSparkData('column', i)
});
column.appendTo('#spkarea' + i);
var winloss = new ej2_react_charts_1.SparklineComponent({
height: '50px',
width: '150px',
type: 'WinLoss',
valueType: 'Numeric',
fill: '#3C78EF',
tiePointColor: 'darkgray',
negativePointColor: '#f7a816',
dataSource: _this.getSparkData('column', i)
});
winloss.appendTo('#spkwl' + i);
}
// tslint:disable-next-line:align
}, 500);
};
SparkGrid.prototype.render = function () {
return (React.createElement("div", { className: 'control-pane' },
React.createElement("style", null, SAMPLE_CSS),
React.createElement("div", { className: 'control-section' },
React.createElement(ej2_react_grids_1.GridComponent, { dataSource: data_source_1.orderdata, resizing: this.renderSparkline.bind(this), load: this.renderSparkline.bind(this), allowSelection: false, enableColumnVirtualization: true, enableHover: true, height: '400' },
React.createElement(ej2_react_grids_1.ColumnsDirective, null,
React.createElement(ej2_react_grids_1.ColumnDirective, { field: 'EmployeeID', headerText: 'ID', textAlign: 'Right', width: '40' }),
React.createElement(ej2_react_grids_1.ColumnDirective, { field: 'CustomerID', headerText: 'Name', width: '60' }),
React.createElement(ej2_react_grids_1.ColumnDirective, { field: 'OrderDate', headerText: 'Order Date', width: '65', format: 'yMd', textAlign: 'Right' }),
React.createElement(ej2_react_grids_1.ColumnDirective, { field: 'ShipCountry', headerText: 'Ship Country', width: '70' }),
React.createElement(ej2_react_grids_1.ColumnDirective, { headerText: 'Tax per annum', template: function (props) {
return (React.createElement("div", { id: "spkline" + props.EmployeeID }));
}, textAlign: 'Center', width: '100' }),
React.createElement(ej2_react_grids_1.ColumnDirective, { headerText: 'One Day Index', template: function (props) {
return (React.createElement("div", { id: "spkarea" + props.EmployeeID }));
}, textAlign: 'Center', width: '100' }),
React.createElement(ej2_react_grids_1.ColumnDirective, { headerText: 'Year GR', template: function (props) {
return (React.createElement("div", { id: "spkwl" + props.EmployeeID }));
}, textAlign: 'Center', width: '100' })))),
React.createElement("div", { id: "action-description" },
React.createElement("p", null, "This sample demonstrates rendering sparklines in data grid control.")),
React.createElement("div", { id: "description" },
React.createElement("p", null, "In this example, you can see how to render sparkline inside the data grid control."))));
};
return SparkGrid;
}(sample_base_1.SampleBase));
exports.SparkGrid = SparkGrid;