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 pathlight-weight.tsx
More file actions
143 lines (140 loc) · 5.91 KB
/
light-weight.tsx
File metadata and controls
143 lines (140 loc) · 5.91 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
/**
* Sample for Light Weight Range Navigator
*/
import * as React from "react";
import * as ReactDOM from "react-dom";
import {
RangeNavigatorComponent, ChartTheme, DateTime, Inject, IChangedEventArgs, IRangeLoadedEventArgs
} from '@syncfusion/ej2-react-charts';
import { Browser } from '@syncfusion/ej2-base';
import { GetDateTimeData } from './data-service';
import { SampleBase } from '../common/sample-base';
export let data: Object[] = GetDateTimeData(new Date(2018, 0, 1), new Date(2019, 0, 1));
const SAMPLE_CSS = `
.control-fluid {
padding: 0px !important;
}
.tableStyle{
transform:translateX(75%);
margin-top:20px;
text-align:center;font-family: Segoe UI;font-weight: 500; font-style:normal; font-size:15px;
}
#rangenavigator {
transform: translate(0, 25%);
}
#days {
font-family: Segoe UI;font-weight: 500; font-style:normal; font-size:15px;
}
#working{
width: 150px;
}
#weekend{
width: 150px;
}
#workingcount{
width: 25px;
}
#weekendcount{
width: 25px;
}
#holiday {
padding-left: 20px;
}
`;
export class LightWeight extends SampleBase<{}, {}> {
render() {
return (
<div className='control-pane'>
<style>
{SAMPLE_CSS}
</style>
<div className='control-section'>
<div className="row">
<div id="days" style={{ textAlign: "center" }}>Calculate the Business and Weekend days in a period</div>
<div id="datetime"></div>
</div>
<div className="row">
<RangeNavigatorComponent id='rangenavigator' style={{ textAlign: "center" }}
valueType='DateTime'
intervalType='Months'
labelFormat='MMM'
height='52'
navigatorStyleSettings={{
thumb: {
type: 'Rectangle'
},
}}
load={this.load.bind(this)}
width={Browser.isDevice ? '100%' : '80%'}
value={[new Date('2018-06-01'), new Date('2018-07-01')]}
dataSource={data} xName='x' yName='y'
changed={this.changed.bind(this)}>
<Inject services={[DateTime]} />
</RangeNavigatorComponent>
</div>
<div className="row">
<table className="tableStyle">
<tbody><tr>
<td id="working1">
<table>
<tbody><tr>
<td id="working" >Total Business Days:</td>
<td id="workingcount"></td>
</tr>
</tbody></table>
</td>
<td id="holiday">
<table>
<tbody><tr>
<td id="weekend">Total Weekend Days: </td>
<td id="weekendcount"></td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
</div>
</div>
<div id="action-description">
<p>
This sample represents the total number of business and weekend days in a selected period.
</p>
</div>
<div id="description">
<p>
In this example, you can see how to render a light-weight range navigator without series.
You can use <code>width</code>, <code>height</code>, <code>fill</code> and <code>boder</code> properties to customize the <code>thumb</code> in range navigator.
You can also change the type of the thumb using <code>type</code> property.
</p>
<br></br>
<p><b>Injecting Module</b></p>
<p>
The range navigator component features are segregated into individual feature-wise modules. To use date-time axis, inject the
<code>DateTime</code> module using the
<code>RangeNavigator.Inject(DateTime)</code> method.
</p>
</div>
</div>
)
}
public changed(args: IChangedEventArgs): void {
let currentDate: Date = new Date(+args.start);
let workingDaysCount: number = 0;
let holidaysDaysCount: number = 0;
while (currentDate <= new Date(+args.end)) {
if (currentDate.getDay() > 0 && currentDate.getDay() <= 5) {
workingDaysCount++;
} else {
holidaysDaysCount++;
}
currentDate.setDate(currentDate.getDate() + 1);
}
document.getElementById('workingcount').innerHTML = ' ' + workingDaysCount;
document.getElementById('weekendcount').innerHTML = ' ' + holidaysDaysCount;
};
public load(args: IRangeLoadedEventArgs): void {
let selectedTheme: string = location.hash.split('/')[1];
selectedTheme = selectedTheme ? selectedTheme : 'Material';
args.rangeNavigator.theme = (selectedTheme.charAt(0).toUpperCase() + selectedTheme.slice(1)) as ChartTheme;
};
}