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 pathsample-data.tsx
More file actions
316 lines (313 loc) · 18.1 KB
/
sample-data.tsx
File metadata and controls
316 lines (313 loc) · 18.1 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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
/**
* Sample for data sample
*/
import * as React from "react";
import * as ReactDOM from "react-dom";
import {
CircularGaugeComponent, AxesDirective, AxisDirective, Inject, ILoadedEventArgs,
PointersDirective, PointerDirective, RangesDirective, RangeDirective,
Annotations, AnnotationDirective, AnnotationsDirective, GaugeTheme,
} from '@syncfusion/ej2-react-circulargauge';
import { GridComponent, ColumnsDirective, ColumnDirective } from '@syncfusion/ej2-react-grids';
import { SampleBase } from '../common/sample-base';
const SAMPLE_CSS = `
.control-fluid {
padding: 0px !important;
}
.imageStyle {
width: 16px;
height: 16px;
margin-top: 4px;
}
.fontDes {
float: right;
padding-left: 5px;
color:#424242;
font-size:20px;
font-family:Roboto";
}
.fontDes1 {
color:#9E9E9E;
font-size:16px;
font-family:Roboto";
}
`;
export class SampleData extends SampleBase<{}, {}> {
private grid1: GridComponent;
public load(args: ILoadedEventArgs): void {
let selectedTheme: string = location.hash.split('/')[1];
selectedTheme = selectedTheme ? selectedTheme : 'Material';
args.gauge.theme = (selectedTheme.charAt(0).toUpperCase() + selectedTheme.slice(1)) as GaugeTheme;
}
private sampleGauge1: CircularGaugeComponent;
private sampleGauge2: CircularGaugeComponent;
private sampleGauge3: CircularGaugeComponent;
public dataInterval1: Object;
public dataInterval2: Object;
public orderData: Object[] = [
{
'Country': 'Germany',
'Sales': 500,
'Target': 400,
'vsTarget': 300
}, {
'Country': 'USA',
'Sales': 1000,
'Target': 600,
'vsTarget': 360
}, {
'Country': 'UK',
'Sales': 600,
'Target': 700,
'vsTarget': -100
}
];
public onChartLoad(args: ILoadedEventArgs): void {
this.dataInterval1 = setInterval(
(): void => {
let value1: number = Math.round(Math.random() * (90 - 55) + 55);
let value2: number = Math.round(Math.random() * (75 - 60) + 60);
let value3: number = Math.round(Math.random() * (40 - 10) + 10);
let gridData1: number = 4 * value1;
let gridData2: number = 6 * value2;
let gridData3: number = 7 * value3;
let newVal: number = Math.random() * (90 - 20) + 20;
if (document.getElementById('sample1-container')) {
this.sampleGauge1.axes[0].pointers[0].animation.enable = true;
this.sampleGauge2.axes[0].pointers[0].animation.enable = true;
this.sampleGauge3.axes[0].pointers[0].animation.enable = true;
this.sampleGauge1.setPointerValue(0, 0, value1);
this.sampleGauge2.setPointerValue(0, 0, value2);
this.sampleGauge3.setPointerValue(0, 0, value3);
this.sampleGauge1.setAnnotationValue(0, 0, this.sampleGauge1.axes[0].annotations[0].content);
this.sampleGauge2.setAnnotationValue(0, 0, this.sampleGauge2.axes[0].annotations[0].content);
this.sampleGauge3.setAnnotationValue(0, 0, this.sampleGauge3.axes[0].annotations[0].content);
this.orderData = [
{
'Country': 'Germany',
'Sales': 500,
'Target': 400,
'vsTarget': gridData1
}, {
'Country': 'USA',
'Sales': 1000,
'Target': 600,
'vsTarget': gridData2
}, {
'Country': 'UK',
'Sales': 600,
'Target': 700,
'vsTarget': -gridData3
}];
} else {
clearInterval(+this.dataInterval1);
}
},
2000
);
};
public onGridLoad(args: {}): void {
this.dataInterval2 = setInterval(
(): void => {
if (document.getElementById('sample1-container')) {
this.grid1.dataSource = this.orderData;
this.grid1.refresh()
} else {
clearInterval(+this.dataInterval2);
}
}, 2000)
}
render() {
return (
<div className='control-pane'>
<style>
{SAMPLE_CSS}
</style>
<div className='control-section'>
<div className="row">
<div className="col-sm-12">
<div className="row">
<div className="col-sm-4">
<CircularGaugeComponent load={this.load.bind(this)} style={{ height: "250px" }} ref={gauge => this.sampleGauge1 = gauge} id='sample1-container'>
<Inject services={[Annotations]} />
<AxesDirective>
<AxisDirective startAngle={230} endAngle={130} minimum={0} maximum={100}
lineStyle={{
width: 0
}}
majorTicks={{
width: 0
}}
minorTicks={{
width: 0
}} labelStyle={{
font: { size: '0' }
}}>
<AnnotationsDirective>
<AnnotationDirective
content='<div id="templateWrap"><img class="imageStyle" src="src/circular-gauge/images/positive.png" /><div class="fontDes">${pointers[0].value}%</div></div></div>'
angle={180} zIndex='1'
radius='30%' />
<AnnotationDirective
content='<div class="fontDes1">Germany</div>'
angle={180} zIndex='1'
radius='65%' />
</AnnotationsDirective>
<RangesDirective>
<RangeDirective start={0} end={50} startWidth={15} endWidth={15} color='#EC121C' />
<RangeDirective start={50} end={100} startWidth={15} endWidth={15} color='#45EA0C' />
</RangesDirective>
<PointersDirective>
<PointerDirective value={75} radius='60%'
animation={{ enable: false }}
color='#777777' pointerWidth={5}
cap={{
radius: 6,
border: { width: 0 },
color: '#777777'
}}
needleTail={{
length: '25%',
color: '#777777'
}}>
</PointerDirective>
</PointersDirective>
</AxisDirective>
</AxesDirective>
</CircularGaugeComponent>
</div>
<div className="col-sm-4">
<CircularGaugeComponent load={this.load.bind(this)} style={{ height: "250px" }} ref={gauge => this.sampleGauge2 = gauge} id='sample2-container'>
<Inject services={[Annotations]} />
<AxesDirective>
<AxisDirective startAngle={230} endAngle={130} minimum={0} maximum={100}
lineStyle={{
width: 0
}}
majorTicks={{
width: 0
}}
minorTicks={{
width: 0
}} labelStyle={{
font: { size: '0' }
}}>
<AnnotationsDirective>
<AnnotationDirective
content='<div id="templateWrap"><img class="imageStyle" src="src/circular-gauge/images/positive.png" /><div class="fontDes">${pointers[0].value}%</div></div></div>'
angle={180} zIndex='1'
radius='30%' />
<AnnotationDirective
content='<div class="fontDes1">USA</div>'
angle={180} zIndex='1'
radius='65%' />
</AnnotationsDirective>
<RangesDirective>
<RangeDirective start={0} end={50} startWidth={15} endWidth={15} color='#EC121C' />
<RangeDirective start={50} end={100} startWidth={15} endWidth={15} color='#45EA0C' />
</RangesDirective>
<PointersDirective>
<PointerDirective value={60} radius='60%'
animation={{ enable: false }}
color='#777777' pointerWidth={5}
cap={{
radius: 6,
border: { width: 0 },
color: '#777777'
}}
needleTail={{
length: '25%',
color: '#777777'
}}>
</PointerDirective>
</PointersDirective>
</AxisDirective>
</AxesDirective>
</CircularGaugeComponent>
</div>
<div className="col-sm-4">
<CircularGaugeComponent load={this.load.bind(this)} style={{ height: "250px" }} ref={gauge => this.sampleGauge3 = gauge} loaded={this.onChartLoad.bind(this)} id='sample3-container'>
<Inject services={[Annotations]} />
<AxesDirective>
<AxisDirective startAngle={230} endAngle={130} minimum={0} maximum={100}
lineStyle={{
width: 0
}}
majorTicks={{
width: 0
}}
minorTicks={{
width: 0
}} labelStyle={{
font: { size: '0' }
}}>
<AnnotationsDirective>
<AnnotationDirective
content='<div id="templateWrap"><img class="imageStyle" src="src/circular-gauge/images/negative.png" /><div class="fontDes">${pointers[0].value}%</div></div></div>'
angle={180} zIndex='1'
radius='30%' />
<AnnotationDirective
content='<div class="fontDes1">UK</div>'
angle={180} zIndex='1'
radius='65%' />
</AnnotationsDirective>
<RangesDirective>
<RangeDirective start={0} end={50} startWidth={15} endWidth={15} color='#EC121C' />
<RangeDirective start={50} end={100} startWidth={15} endWidth={15} color='#45EA0C' />
</RangesDirective>
<PointersDirective>
<PointerDirective value={25} radius='60%'
animation={{ enable: false }}
color='#777777' pointerWidth={5}
cap={{
radius: 6,
border: { width: 0 },
color: '#777777'
}}
needleTail={{
length: '25%',
color: '#777777'
}}>
</PointerDirective>
</PointersDirective>
</AxisDirective>
</AxesDirective>
</CircularGaugeComponent>
</div>
</div>
</div>
</div>
<div className="row">
<div className="col-sm-12">
<div className="row">
<GridComponent dataBound={this.onGridLoad.bind(this)} ref={grid => this.grid1 = grid} dataSource={this.orderData.slice(0, 30)}>
<ColumnsDirective>
<ColumnDirective field='Country' headerText='Country' width='80'></ColumnDirective>
<ColumnDirective field='Sales' headerText='Sales $' width='80'></ColumnDirective>
<ColumnDirective field='Target' headerText='Target $' width='80' />
<ColumnDirective field='vsTarget' headerText='vs Target' width='80' />
</ColumnsDirective>
</GridComponent>
</div>
</div>
</div>
<div id="action-description">
<p>
This sample demonstrates the live data sample in circular gauge.
</p>
</div>
<div id="description">
<p>
Pointer values in the gauge can be updated dynamically by using <code>setPointerValue</code> method.
In this example, a stock price changes over the countries, are showed by using a gauge.
</p>
<p>
More information on the gauge and its methods can be found in can be found in this
<a target="_blank" href="http://ej2.syncfusion.com/documentation"> documentation section</a>.
</p>
</div>
</div>
</div>
)
}
}