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 pathdirection.tsx
More file actions
160 lines (158 loc) · 8.13 KB
/
direction.tsx
File metadata and controls
160 lines (158 loc) · 8.13 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
/**
* Sample for direction compass
*/
import * as React from "react";
import * as ReactDOM from "react-dom";
import { PropertyPane } from '../common/property-pane';
import {
CircularGaugeComponent, AxesDirective, AxisDirective, Inject, ILoadedEventArgs, GaugeTheme,
PointersDirective, PointerDirective, RangesDirective, RangeDirective, IAxisLabelRenderEventArgs
} from '@syncfusion/ej2-react-circulargauge';
import { SampleBase } from '../common/sample-base';
import { DropDownList } from '@syncfusion/ej2-dropdowns';
const SAMPLE_CSS = `
.control-fluid {
padding: 0px !important;
}`;
export class Direction extends SampleBase<{}, {}> {
private gauge: CircularGaugeComponent;
public pointerColor: DropDownList; public labelColor: DropDownList;
private loaded: boolean = false;
public onLabelRender(args: IAxisLabelRenderEventArgs): void {
args.text = ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW', ''][args.value];
};
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;
}
public onChartLoad(args: {}): void {
if (!this.loaded) {
this.loaded = true;
this.pointerColor = new DropDownList({
index: 0,
placeholder: 'Select Range Bar Color',
width: 100,
change: () => {
let rangeColor: string = this.pointerColor.value.toString();
this.gauge.axes[0].pointers[0].color = rangeColor;
this.gauge.setPointerValue(0, 0, this.gauge.axes[0].pointers[0].value);
}
});
this.pointerColor.appendTo('#poiterColor');
this.labelColor = new DropDownList({
index: 0,
placeholder: 'Select Range Bar Color',
width: 100,
change: () => {
let rangeColor: string = this.labelColor.value.toString();
this.gauge.axes[0].ranges[0].color = rangeColor;
this.gauge.refresh();
}
});
this.labelColor.appendTo('#labelColor');
}
}
render() {
return (
<div className='control-pane'>
<div className='control-section row'>
<div className='col-lg-8'>
<CircularGaugeComponent load={this.load.bind(this)} id='direction-gauge' ref={gauge => this.gauge = gauge}
axisLabelRender={this.onLabelRender.bind(this)} loaded={this.onChartLoad.bind(this)}>
<AxesDirective>
<AxisDirective radius='70%' startAngle={0} endAngle={360}
minimum={0} maximum={8}
majorTicks={{
height: 15,
interval: 1,
color: '#9E9E9E'
}} lineStyle={{ width: 10, color: '#E0E0E0' }}
minorTicks={{
height: 10,
interval: 0.5,
color: '#9E9E9E'
}} labelStyle={{
font: {
size: '12px', fontFamily: 'Roboto'
},
useRangeColor: true,
autoAngle: true,
hiddenLabel: 'Last'
}}>
<PointersDirective>
<PointerDirective value={7} radius='50%' color='#f03e3e' pointerWidth={20} cap={{
radius: 0
}} animation={{
enable: false
}} />
<PointerDirective value={3} radius='50%' color='#9E9E9E' pointerWidth={20} cap={{
radius: 0
}} animation={{
enable: false
}} />
</PointersDirective>
<RangesDirective>
<RangeDirective start={7} end={7} color='#f03e3e' />
</RangesDirective>
</AxisDirective>
</AxesDirective>
</CircularGaugeComponent>
</div>
<div className='col-lg-4 property-section'>
<PropertyPane title='Properties'>
<table id='property' title='Properties' className='property-panel-table' style={{ width: '100%' }}>
<tbody>
<tr style={{ height: '50px' }}>
<td>
<div id=''>Pointer Color</div>
</td>
<td>
<div>
<select id="poiterColor" className="form-control">
<option value="#f03e3e">#f03e3e</option>
<option value="#4472c4">#4472c4</option>
<option value="#ed7d31">#ed7d31</option>
</select>
</div>
</td>
</tr>
<tr style={{ height: '50px' }}>
<td>
<div id=''>Label Color</div>
</td>
<td>
<div>
<select id="labelColor" className="form-control">
<option value="#f03e3e">#f03e3e</option>
<option value="#4472c4">#4472c4</option>
<option value="#ed7d31">#ed7d31</option>
</select>
</div>
</td>
</tr>
</tbody>
</table>
</PropertyPane>
</div>
</div>
<div id="action-description">
<p>
This sample illustrates how to make a direction compass by using the features in gauge.
Color of the needle and direction labels can be customized by using options.
</p>
</div>
<div id="description">
<p>
Circular gauge can be customized as per a user requirement.
In this example, a direction compass has been depicted by adding <code>needles</code> and by customizing the <code>labels</code> to show the direction.
</p>
<p>
More information on the needle and labels can be found in this
<a target="_blank" href="http://ej2.syncfusion.com/documentation"> documentation section</a>.
</p>
</div>
</div>
)
}
}