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 pathcustomization.js
More file actions
292 lines (292 loc) · 18.5 KB
/
customization.js
File metadata and controls
292 lines (292 loc) · 18.5 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
"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 Gauge Customization
*/
var React = require("react");
var property_pane_1 = require("../common/property-pane");
var ej2_react_circulargauge_1 = require("@syncfusion/ej2-react-circulargauge");
var sample_base_1 = require("../common/sample-base");
var ej2_circulargauge_1 = require("@syncfusion/ej2-circulargauge");
var customization_service_1 = require("./customization-service");
var ej2_dropdowns_1 = require("@syncfusion/ej2-dropdowns");
var SAMPLE_CSS = "\n .control-fluid {\n\t\tpadding: 0px !important;\n }";
var Customization = (function (_super) {
__extends(Customization, _super);
function Customization() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.usageGauge = new ej2_circulargauge_1.CircularGauge(customization_service_1.DynamicDataSerive.prototype.GetSubGauge1().gauge1);
_this.randomGauge = new ej2_circulargauge_1.CircularGauge(customization_service_1.DynamicDataSerive.prototype.GetSubGauge1().gauge2);
_this.isUsage = false;
_this.isClicked = true;
_this.loaded = false;
return _this;
}
Customization.prototype.load = function (args) {
var selectedTheme = location.hash.split('/')[1];
selectedTheme = selectedTheme ? selectedTheme : 'Material';
args.gauge.theme = (selectedTheme.charAt(0).toUpperCase() + selectedTheme.slice(1));
};
Customization.prototype.random = function () {
if (this.isClicked) {
this.gauge1.destroy();
this.isClicked = false;
}
else {
this.usageGauge.destroy();
}
this.randomGauge.appendTo('#customization-container');
this.isUsage = false;
this.pointerValueElement.min = '1000';
this.pointerValueElement.max = '2000';
this.pointerValueElement.value = this.randomGauge.axes[0].pointers[0].value.toString();
document.getElementById('currentPointerValue').innerHTML = 'Current Value <span> ' + this.randomGauge.axes[0].pointers[0].value + '</span>';
this.barColor.value = this.randomGauge.axes[0].pointers[0].color;
this.rangeColor.value = this.randomGauge.axes[0].ranges[0].color;
this.pointerColor.value = this.randomGauge.axes[0].pointers[1].color;
this.pointerColor.enabled = true;
document.getElementById('pointColor').className = 'e-enabled';
document.getElementById('pointColor').style.visibility = 'visible';
var currentLine = document.getElementById('random_line');
var exisLine = document.getElementById('usage_line');
currentLine.style.display = 'block';
exisLine.style.display = 'none';
};
Customization.prototype.usage = function () {
if (this.isClicked) {
this.gauge1.destroy();
this.isClicked = false;
}
else {
this.randomGauge.destroy();
}
this.usageGauge.appendTo('#customization-container');
this.isUsage = true;
this.pointerValueElement.min = '0.5';
this.pointerValueElement.max = '100';
this.pointerValueElement.value = this.usageGauge.axes[0].pointers[0].value.toString();
document.getElementById('currentPointerValue').innerHTML = 'Current Value <span> ' + this.usageGauge.axes[0].pointers[0].value + '</span>';
this.barColor.value = this.usageGauge.axes[0].pointers[0].color;
this.rangeColor.value = this.usageGauge.axes[0].ranges[0].color;
this.pointerColor.enabled = false;
document.getElementById('pointColor').className = 'e-disabled';
var currentLine = document.getElementById('usage_line');
var exisLine = document.getElementById('random_line');
currentLine.style.display = 'block';
exisLine.style.display = 'none';
};
Customization.prototype.pointerValue = function () {
var value = +this.pointerValueElement.value;
if (!this.isClicked) {
if (this.isUsage) {
this.usageGauge.setPointerValue(0, 0, value);
this.usageGauge.setAnnotationValue(0, 0, '<div style="color:#666666;font-size:35px;">' + value + 'GB' + '</div>');
}
else {
this.randomGauge.setPointerValue(0, 0, value);
this.randomGauge.setPointerValue(0, 1, value);
this.randomGauge.setAnnotationValue(0, 0, '<div style="color:#666666;font-size:35px;">' + value + '' + '</div>');
}
}
else {
this.gauge1.setPointerValue(0, 0, value);
this.gauge1.setPointerValue(0, 1, value);
this.gauge1.setAnnotationValue(0, 0, '<div style="color:#666666;font-size:35px;">' + value + '' + '</div>');
this.randomGauge.axes[0].pointers[0].value = value;
this.randomGauge.axes[0].pointers[1].value = value;
this.randomGauge.axes[0].annotations[0].content = '<div style="color:#666666;font-size:35px;">' + value + '' + '</div>';
}
document.getElementById('currentPointerValue').innerHTML = 'Current Value <span> ' + value + '</span>';
};
Customization.prototype.render = function () {
var _this = this;
return (React.createElement("div", { className: 'control-pane' },
React.createElement("div", { className: 'control-section row' },
React.createElement("div", { className: 'col-lg-8' },
React.createElement(ej2_react_circulargauge_1.CircularGaugeComponent, { load: this.load.bind(this), id: 'customization-container', loaded: this.onChartLoad.bind(this), ref: function (gauge) { return _this.gauge1 = gauge; }, centerY: '70%' },
React.createElement(ej2_react_circulargauge_1.Inject, { services: [ej2_react_circulargauge_1.Annotations] }),
React.createElement(ej2_react_circulargauge_1.AxesDirective, null,
React.createElement(ej2_react_circulargauge_1.AxisDirective, { startAngle: 300, endAngle: 60, radius: '80%', minimum: 999, maximum: 2000, majorTicks: {
width: 0
}, lineStyle: { width: 0 }, minorTicks: {
width: 0
}, labelStyle: {
font: { size: '0px' }
} },
React.createElement(ej2_react_circulargauge_1.AnnotationsDirective, null,
React.createElement(ej2_react_circulargauge_1.AnnotationDirective, { content: '<div style="color:#666666;font-size:35px;">1800</div>', angle: 0, radius: '110%', zIndex: '1' })),
React.createElement(ej2_react_circulargauge_1.PointersDirective, null,
React.createElement(ej2_react_circulargauge_1.PointerDirective, { type: 'RangeBar', value: 1800, radius: '90%', color: '#FFDD00', pointerWidth: 30, animation: {
duration: 0
} }),
React.createElement(ej2_react_circulargauge_1.PointerDirective, { value: 1800, radius: '90%', color: '#424242', pointerWidth: 9, cap: { radius: 10, color: '#424242', border: { width: 0 } }, animation: {
duration: 0
} })),
React.createElement(ej2_react_circulargauge_1.RangesDirective, null,
React.createElement(ej2_react_circulargauge_1.RangeDirective, { start: 1000, end: 2000, radius: '90%', color: '#E0E0E0', startWidth: 30, endWidth: 30 })))))),
React.createElement("div", { className: 'col-lg-4 property-section' },
React.createElement(property_pane_1.PropertyPane, { title: 'Properties' },
React.createElement("table", { id: 'property', title: 'Properties', className: 'property-panel-table', style: { width: '100%' } },
React.createElement("tbody", null,
React.createElement("tr", { style: { height: '50px' } },
React.createElement("td", null,
React.createElement("img", { id: 'random', src: "src/circular-gauge/images/gauge-1.png", style: { marginLeft: '25px', marginTop: '10px' }, onClick: this.random.bind(this), ref: function (d) { return _this.image1 = d; } }),
React.createElement("div", { id: "random_line", style: { display: "block", left: "0px", background: "#ff4081", "padding-top": "0px", height: "2px", width: "85px", margin: "2px 2px 2px 17px" } })),
React.createElement("td", null,
React.createElement("img", { id: 'usage', src: "src/circular-gauge/images/gauge-2.png", style: { marginLeft: '25px', marginTop: '10px' }, onClick: this.usage.bind(this), ref: function (d) { return _this.image2 = d; } }),
React.createElement("div", { id: "usage_line", style: { display: "none", left: "0px", background: "#ff4081", "padding-top": "0px", height: "2px", width: "85px", margin: "2px 2px 2px 17px" } }))),
React.createElement("tr", { style: { height: '50px' } },
React.createElement("td", null,
React.createElement("div", { id: 'currentPointerValue' },
"Current Value ",
React.createElement("span", null, " \u00A0\u00A0\u00A01800"),
" ")),
React.createElement("td", null,
React.createElement("div", null,
React.createElement("input", { type: "range", id: "currentValue", defaultValue: "1800", min: "1000", max: "2000", style: { width: "90%" }, onChange: this.pointerValue.bind(this), ref: function (d) { return _this.pointerValueElement = d; } })))),
React.createElement("tr", { style: { height: '50px' } },
React.createElement("td", null,
React.createElement("div", { id: 'rangebarColor' }, "RangeBar Color")),
React.createElement("td", null,
React.createElement("div", null,
React.createElement("select", { id: "barColor", className: "form-control" },
React.createElement("option", { value: "#FFDD00" }, "#FFDD00"),
React.createElement("option", { value: "#00bdae" }, "#00bdae"),
React.createElement("option", { value: "#FF2680" }, "#FF2680"))))),
React.createElement("tr", { style: { height: '50px' } },
React.createElement("td", null,
React.createElement("div", { id: 'range' }, "Range Color")),
React.createElement("td", null,
React.createElement("div", null,
React.createElement("select", { id: "rangeColor", className: "form-control" },
React.createElement("option", { value: "#E0E0E0" }, "#E0E0E0"),
React.createElement("option", { value: "#7bb4eb" }, "#7bb4eb"),
React.createElement("option", { value: "#ea7a57" }, "#ea7a57"))))),
React.createElement("tr", { style: { height: '50px' } },
React.createElement("td", null,
React.createElement("div", { id: 'pointColor' }, "Pointer Color")),
React.createElement("td", null,
React.createElement("div", null,
React.createElement("select", { id: "pointerColor", className: "form-control" },
React.createElement("option", { value: "#424242" }, "#424242"),
React.createElement("option", { value: "#6f6fe2" }, "#6f6fe2"),
React.createElement("option", { value: "#9e480e" }, "#9e480e")))))))))),
React.createElement("div", { id: "action-description" },
React.createElement("p", null, "This sample illustrates how to customize the gauge with pointers. Options to change the color and type of the pointer are available in the property panel.")),
React.createElement("div", { id: "description" },
React.createElement("p", null,
"In this example, you can see how to customize the gauge elements such as ",
React.createElement("code", null, "pointers"),
" and ",
React.createElement("code", null, "range"),
". Here a needle and range bar are added to show the current value and its appearance can be customized by using options in property panel."),
React.createElement("p", null,
"More information on the range and pointer customization can be found in this",
React.createElement("a", { target: "_blank", href: "http://ej2.syncfusion.com/documentation" }, " documentation section"),
"."))));
};
Customization.prototype.onChartLoad = function (args) {
var _this = this;
if (!this.loaded) {
this.loaded = true;
this.barColor = new ej2_dropdowns_1.DropDownList({
index: 0,
width: 130,
change: function () {
var barColor = _this.barColor.value.toString();
if (!_this.isClicked) {
if (_this.isUsage) {
_this.usageGauge.axes[0].pointers[0].color = barColor;
_this.usageGauge.refresh();
}
else {
_this.randomGauge.axes[0].pointers[0].color = barColor;
_this.randomGauge.refresh();
}
}
else {
_this.gauge1.axes[0].pointers[0].color = barColor;
_this.gauge1.refresh();
_this.randomGauge.axes[0].pointers[0].color = barColor;
}
}
});
this.barColor.appendTo('#barColor');
this.rangeColor = new ej2_dropdowns_1.DropDownList({
index: 0,
width: 130,
change: function () {
var barColor = _this.rangeColor.value.toString();
if (!_this.isClicked) {
if (_this.isUsage) {
_this.usageGauge.axes[0].ranges[0].color = barColor;
_this.usageGauge.refresh();
}
else {
_this.randomGauge.axes[0].ranges[0].color = barColor;
_this.randomGauge.refresh();
}
}
else {
_this.gauge1.axes[0].ranges[0].color = barColor;
_this.gauge1.refresh();
_this.randomGauge.axes[0].ranges[0].color = barColor;
}
}
});
this.rangeColor.appendTo('#rangeColor');
this.pointerColor = new ej2_dropdowns_1.DropDownList({
index: 0,
width: 130,
change: function () {
var barColor = _this.pointerColor.value.toString();
if (!_this.isClicked) {
if (!_this.isUsage) {
_this.randomGauge.axes[0].pointers[1].color = barColor;
_this.randomGauge.axes[0].pointers[1].cap.border.color = barColor;
_this.randomGauge.axes[0].pointers[1].cap.color = barColor;
_this.randomGauge.refresh();
}
}
else {
_this.gauge1.axes[0].pointers[1].color = barColor;
_this.gauge1.axes[0].pointers[1].cap.border.color = barColor;
_this.gauge1.axes[0].pointers[1].cap.color = barColor;
_this.gauge1.refresh();
_this.randomGauge.axes[0].pointers[1].color = barColor;
_this.randomGauge.axes[0].pointers[1].cap.border.color = barColor;
_this.randomGauge.axes[0].pointers[1].cap.color = barColor;
}
}
});
this.pointerColor.appendTo('#pointerColor');
}
var selectedTheme = location.hash.split('/')[1];
var color;
if (selectedTheme === 'bootstrap') {
color = '#a16ee5';
}
else if (selectedTheme === 'fabric') {
color = '#1783FF';
}
else {
color = '#ff4081';
}
var exisLine = document.getElementById('usage_line');
var currentLine = document.getElementById('random_line');
exisLine.style.background = color;
currentLine.style.background = color;
};
return Customization;
}(sample_base_1.SampleBase));
exports.Customization = Customization;