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 pathaxes.tsx
More file actions
211 lines (204 loc) · 11.7 KB
/
axes.tsx
File metadata and controls
211 lines (204 loc) · 11.7 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
/**
* Sample for Axes
*/
import * as React from "react";
import * as ReactDOM from "react-dom";
import { LinearGaugeComponent, ILoadedEventArgs, LinearGaugeTheme, Point, MarkerType, Placement, AxesDirective, Annotations, AxisDirective, PointersDirective, PointerDirective, AnnotationDirective, AnnotationsDirective, Inject, Pointer } from '@syncfusion/ej2-react-lineargauge';
import { PropertyPane } from '../common/property-pane';
import { SampleBase } from '../common/sample-base';
import { DropDownListComponent } from '@syncfusion/ej2-react-dropdowns';
export class Axes extends SampleBase<{}, {}> {
private gaugeInstance: LinearGaugeComponent;
private rangeMinElement: HTMLInputElement;
private rangeMaxElement: HTMLInputElement;
private inversedElement: HTMLInputElement;
private opposedElement: HTMLInputElement;
private labelElement: HTMLInputElement;
private typeElement: DropDownListComponent;
private placeElement: DropDownListComponent;
private markerElement: HTMLSelectElement;
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 LinearGaugeTheme;
}
private minChange() {
this.gaugeInstance.axes[0].minimum = parseInt(this.rangeMinElement.value, 10);
document.getElementById('minValue').innerHTML = 'Axis Minimum <span> ' + this.rangeMinElement.value;
this.gaugeInstance.annotations[0].axisValue = (this.gaugeInstance.axes[0].pointers[0] as Pointer).currentValue;
this.gaugeInstance.refresh();
}
private maxChange() {
this.gaugeInstance.axes[0].maximum = parseInt(this.rangeMaxElement.value, 10);
document.getElementById('maxValue').innerHTML = 'Axis Maximum <span> ' + this.rangeMaxElement.value;
this.gaugeInstance.annotations[0].axisValue = (this.gaugeInstance.axes[0].pointers[0] as Pointer).currentValue;
this.gaugeInstance.refresh();
}
private inverseChange() {
this.gaugeInstance.axes[0].isInversed = this.inversedElement.checked;
this.gaugeInstance.refresh();
}
private opposedChange() {
this.gaugeInstance.axes[0].opposedPosition = this.opposedElement.checked;
if (this.opposedElement.checked) {
this.gaugeInstance.axes[0].pointers[0].placement = 'Near';
this.gaugeInstance.axes[0].pointers[0].markerType = 'Triangle';
this.gaugeInstance.axes[0].pointers[0].offset = -20;
this.gaugeInstance.axes[0].labelStyle.offset = 0;
this.gaugeInstance.annotations[0].x = 10;
this.gaugeInstance.annotations[0].y = -60;
} else {
this.gaugeInstance.axes[0].pointers[0].placement = 'Far';
this.gaugeInstance.axes[0].pointers[0].offset = 0;
this.gaugeInstance.axes[0].pointers[0].offset = 30;
this.gaugeInstance.axes[0].pointers[0].markerType = 'InvertedTriangle';
this.gaugeInstance.axes[0].labelStyle.offset = 38;
this.gaugeInstance.annotations[0].x = 10;
this.gaugeInstance.annotations[0].y = 60;
}
this.gaugeInstance.refresh();
}
private labelChange() {
this.gaugeInstance.axes[0].labelStyle.format = this.labelElement.value.indexOf('{value}') > -1 ? this.labelElement.value : this.gaugeInstance.axes[0].labelStyle.format;
this.gaugeInstance.refresh();
}
private typeChange() {
this.gaugeInstance.axes[0].pointers[0].type = this.typeElement.value as Point;
this.placeElement.enabled = (this.typeElement.value === 'Marker');
this.gaugeInstance.refresh();
}
private placeChange() {
this.gaugeInstance.axes[0].pointers[0].placement = this.placeElement.value as Placement;
this.gaugeInstance.refresh();
}
private droplist: { [key: string]: Object }[] = [
{ value: 'Marker'},
{ value: 'Bar'}
];
private placelist: { [key: string]: Object }[] = [
{ value: 'Near'},
{ value: 'Center'},
{ value: 'Far'}
];
render() {
return (
<div className='control-pane'>
<div className='control-section row'>
<div className='col-lg-8'>
<LinearGaugeComponent load={this.load.bind(this)} id='gauge' ref={gauge => this.gaugeInstance = gauge} orientation='Horizontal'>
<Inject services={[Annotations]} />
<AxesDirective>
<AxisDirective line={{ color: '#9E9E9E' }} majorTicks={{ color: '#9E9E9E', interval: 10 }} minorTicks={{ color: '#9E9E9E', interval: 2 }} labelStyle={{ offset: 48 }}>
<PointersDirective>
<PointerDirective value={10} height={15} width={15} color='#757575' offset={30}>
</PointerDirective>
</PointersDirective>
</AxisDirective>
</AxesDirective>
<AnnotationsDirective>
<AnnotationDirective content='<div id="pointer" style="width:70px"><h1 style="font-size:14px;">${axes[0].pointers[0].currentValue} MPH</h1></div>'
axisIndex={0}
axisValue={10}
x={10}
y={60}
zIndex='1'>
</AnnotationDirective>
</AnnotationsDirective>
</LinearGaugeComponent>
</div>
<div className='col-lg-4 property-section'>
<PropertyPane title='Properties'>
<table id='property' title='Properties' className='property-panel-table' style={{ width: '100%', marginBottom: '20px' }}>
<tr style={{ height: '50px' }}>
<td style={{ width: '30%' }}>
<div id='minValue'>Axis Minimum <span> 40</span> </div>
</td>
<td style={{ width: '70%' }}>
<div data-role='rangeslider'>
<input type="range" onChange={this.minChange.bind(this)} ref={d => this.rangeMinElement = d} name="range-min" step='5' id="min" defaultValue="0" min="0" max="100" style={{ width: '100px' }} />
</div>
</td>
</tr>
<tr style={{ height: '50px' }}>
<td style={{ width: '30%' }}>
<div id='maxValue'>Axis Maximum <span> 80</span> </div>
</td>
<td style={{ width: '70%' }}>
<div data-role='rangeslider'>
<input type="range" onChange={this.maxChange.bind(this)} ref={d => this.rangeMaxElement = d} step='5' id="max" defaultValue="80" min="0" max="100" style={{ width: '100px' }} />
</div>
</td>
</tr>
<tr>
<td>
<div>Axis Inversed</div>
</td>
<td>
<div>
<input type="checkbox" onChange={this.inverseChange.bind(this)} ref={d => this.inversedElement = d} id='axisInversed' />
</div>
</td>
</tr>
<tr>
<td>
<div>Axis Opposed</div>
</td>
<td>
<div>
<input type="checkbox" onChange={this.opposedChange.bind(this)} ref={d => this.opposedElement = d} id='opposed' />
</div>
</td>
</tr>
<tr>
<td>
<div>Label Format</div>
</td>
<td>
<div className="e-float-input" style={{ 'margin-top': '0px' }}>
<input id="format" onChange={this.labelChange.bind(this)} ref={d => this.labelElement = d} type="text" defaultValue="{value}" style={{ "width": "100px" }} />
</div>
</td>
</tr>
<tr>
<td>
<div>Pointer type</div>
</td>
<td>
<div>
<DropDownListComponent width={120} id="pointerType" style={{ "width": "auto" }} change={this.typeChange.bind(this)} ref={d => this.typeElement = d} dataSource={this.droplist} fields={{ text: 'value', value: 'value' }} value="Marker" />
</div>
</td>
</tr>
<tr>
<td>
<div>Marker Placement</div>
</td>
<td>
<div>
<DropDownListComponent width={120} id="pointerPlace" style={{ "width": "auto" }} change={this.placeChange.bind(this)} ref={d => this.placeElement = d} dataSource={this.placelist} fields={{ text: 'value', value: 'value' }} value="Far" />
</div>
</td>
</tr>
</table>
</PropertyPane>
</div>
</div>
<div id="action-description">
<p>
This sample illustrates the axis and pointers feature in the linear gauge. Axis and pointers can be customized by using options available in the panel.
</p>
</div>
<div id="description">
<p>
In this example, you can see how to customize the axes and pointers. Use <code>format</code> of labelStyle property
to customize the axis labels and use <code>type</code>, <code>markerType</code> and <code>placement</code> properties
to customize the pointers in linear gauge.
</p>
<p>
More information about linear gauge can be found in this <a target="_blank" href="http://ej2.syncfusion.com/documentation">documentation section</a>.
</p>
</div>
</div >
)
}
}