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 pathdefault.tsx
More file actions
147 lines (138 loc) · 6.37 KB
/
default.tsx
File metadata and controls
147 lines (138 loc) · 6.37 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
/**
* Sample for Default Range Navigator
*/
import * as React from "react";
import * as ReactDOM from "react-dom";
import {
RangeNavigatorComponent, AreaSeries, ChartTheme, DateTime, Inject, RangeTooltip,
RangenavigatorSeriesCollectionDirective, RangenavigatorSeriesDirective, IRangeLoadedEventArgs
} from '@syncfusion/ej2-react-charts';
import { Browser } from '@syncfusion/ej2-base';
import { bitCoinData } from './default-data';
import { SampleBase } from '../common/sample-base';
export let data: Object[] = bitCoinData;
export let themes: string[] = ['Material' , 'Fabric' , 'Bootstrap' , 'Highcontrast']
export let borderColor: string[] = ['#00bdae', '#4472c4', '#a16ee5', '#79ECE4'];
export let regionColor: string[] = ['rgba(0, 189, 174, 0.3)', 'rgba(68, 114, 196, 0.3)',
'rgba(161, 110, 229, 0.3)', 'rgba(121, 236, 228, 0.3)'];
const SAMPLE_CSS = `
.control-fluid {
padding: 0px !important;
}
#title{
font-size: 15px;
font-style: normal;
font-family: "Segoe UI";
font-weight: 500;
text-anchor: middle;
transform: none;
opacity: 1;
}
#rangenavigator {
transform: translate(0, 25%);
}
#material-gradient-chart stop {
stop-color: #00bdae;
}
#fabric-gradient-chart stop {
stop-color: #4472c4;
}
#bootstrap-gradient-chart stop {
stop-color: #a16ee5;
}
#highcontrast-gradient-chart stop {
stop-color: #79ECE4;
}
.chart-gradient stop[offset="0"] {
stop-opacity: 0.9;
}
.chart-gradient stop[offset="1"] {
stop-opacity: 0.3;
}
`;
export class Default extends SampleBase<{}, {}> {
render() {
return (
<div className='control-pane'>
<style>
{SAMPLE_CSS}
</style>
<div className='control-section'>
<div className="row" style={{ textAlign: "center" }}>
<div id="title">Bitcoin (USD) Price Range</div>
</div>
<div className="row">
<RangeNavigatorComponent id='rangenavigator' style={{ textAlign: "center" }}
valueType='DateTime'
load={this.load.bind(this)}
tooltip={{ enable: true, displayMode: 'Always',format: 'MM/dd/yyyy' }}
navigatorStyleSettings={{
unselectedRegionColor: 'transparent'
}}
labelFormat='MMM-yy'
width={Browser.isDevice ? '100%' : '80%'}
value={[new Date('2017-09-01'), new Date('2018-02-01')]}>
<Inject services={[AreaSeries, DateTime, RangeTooltip]} />
<RangenavigatorSeriesCollectionDirective>
<RangenavigatorSeriesDirective dataSource={data} xName='x' yName='y'
type='Area' width={2} border={{width:2}}>
</RangenavigatorSeriesDirective>
</RangenavigatorSeriesCollectionDirective>
</RangeNavigatorComponent>
</div>
</div>
<svg style={{ height: '0' }}>
<defs>
<linearGradient id="material-gradient-chart" style={{opacity: 0.75}} className="chart-gradient" x1="0" x2="0" y1="0" y2="1">
<stop offset="0"></stop>
<stop offset="1"></stop>
</linearGradient>
<linearGradient id="fabric-gradient-chart" style={{opacity: 0.75}} className="chart-gradient" x1="0" x2="0" y1="0" y2="1">
<stop offset="0"></stop>
<stop offset="1"></stop>
</linearGradient>
<linearGradient id="bootstrap-gradient-chart" style={{opacity: 0.75}} className="chart-gradient" x1="0" x2="0" y1="0" y2="1">
<stop offset="0"></stop>
<stop offset="1"></stop>
</linearGradient>
<linearGradient id="highcontrast-gradient-chart" style={{opacity: 0.75}} className="chart-gradient" x1="0" x2="0" y1="0" y2="1">
<stop offset="0"></stop>
<stop offset="1"></stop>
</linearGradient>
</defs>
</svg>
<div id="action-description">
<p>
This sample visualizes the bitcoin price range with area series in the range navigator.
Selected range values are enhanced with tooltip.
</p>
</div>
<div id="description">
<p>
In this example, you can see how to render and configure the range navigator with area type series. <code>Tooltip</code> is used to represent selected data value.
You can also use <code>selectedRegionColor</code> and <code>unselectedRegionColor</code> properties to customize selected and unselected area in range navigator.
</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
<code>RangeNavigator.Inject(DateTime)</code> method.To use tooltip, inject the
<code>RangeTooltip</code> module using
<code>RangeNavigator.Inject(RangeTooltip)</code> method.
</p>
</div>
</div>
)
}
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;
let rangeTheme: string= args.rangeNavigator.theme;
args.rangeNavigator.series[0].fill = 'url(#' + rangeTheme.toLowerCase() + '-gradient-chart)';
args.rangeNavigator.series[0].border.color = borderColor[themes.indexOf(rangeTheme)];
args.rangeNavigator.navigatorStyleSettings.selectedRegionColor= regionColor[themes.indexOf(rangeTheme)];
};
}