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 pathcross-hair.tsx
More file actions
112 lines (110 loc) · 5.36 KB
/
cross-hair.tsx
File metadata and controls
112 lines (110 loc) · 5.36 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
/**
* Sample for Crosshair in chart
*/
import * as React from "react";
import * as ReactDOM from "react-dom";
import {
ChartComponent, SeriesCollectionDirective, SeriesDirective, AxesDirective, AxisDirective, Inject,
LineSeries, HiloOpenCloseSeries, Crosshair, DateTime, ILoadedEventArgs, ChartTheme
} from '@syncfusion/ej2-react-charts';
import { SampleBase } from '../common/sample-base';
import { axesData } from './financial-data';
import { Browser } from '@syncfusion/ej2-base';
/**
* Crosshair sample
*/
export class CrosshairChart extends SampleBase<{}, {}> {
render() {
return (
<div className='control-pane'>
<div className='control-section'>
<ChartComponent id='charts' style={{ textAlign: "center" }}
primaryXAxis={{
majorGridLines: { width: 0 },
valueType: 'DateTime',
crosshairTooltip: { enable: true },
labelFormat: 'MMM'
}}
load={this.load.bind(this)}
primaryYAxis={{
minimum: 83, maximum: 87, interval: 1,
title: 'Millions in USD',
labelFormat: '{value}M',
rowIndex: 0,
crosshairTooltip: {
enable: true
}
}}
width={Browser.isDevice ? '100%' : '80%'}
title='Conns,Inc Stock Details' loaded={this.onChartLoad.bind(this)}
crosshair={{ enable: true }}
legendSettings={{ visible: false }}>
<Inject services={[LineSeries, HiloOpenCloseSeries, Crosshair, DateTime]} />
<AxesDirective>
<AxisDirective majorGridLines={{ width: 0 }}
rowIndex={0}
opposedPosition={true}
minimum={82} maximum={88} interval={2}
name='yAxis'
title='Millions in USD (Stock)'
crosshairTooltip={{ enable: true }}>
</AxisDirective>
</AxesDirective>
<SeriesCollectionDirective>
<SeriesDirective type='Line'
dataSource={axesData}
border={{ width: 1.5 }}
xName='xDate' width={2}
yName='High'
marker={{
visible: true
}}>
</SeriesDirective>
<SeriesDirective type='HiloOpenClose'
dataSource={axesData}
yAxisName='yAxis'
border={{ width: 1.5 }}
bearFillColor='#2ecd71' bullFillColor='#e74c3d'
xName='xDate' width={2}
high='High' low='Low' open='Open' close='Close'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
</div>
<div id="action-description">
<p>
This sample illustrates crosshair feature in chart. To see crosshair, hover or long press the chart.
</p>
</div>
<div id="description">
<p>
This sample demonstrates the crosshair behavior in chart. Crosshair is used to inspect or focus on an individual data point.
You can customize the axis tooltip using <code>crosshairTooltip</code> properties in axis.
</p>
<p>
Hover the chart area to view crosshair and its tooltip. Touch and hold to enable crosshair in touch enabled devices.
</p>
<br></br>
<p><b>Injecting Module</b></p>
<p>
Chart component features are segregated into individual feature-wise modules. To use Crosshair, we need to inject
<code>Crosshair</code> module into <code>services</code>.
</p>
<p>
More information on the Crosshair can be found in this
<a target="_blank" href="http://ej2.syncfusion.com/react/documentation/chart/api-crosshairSettings.html">documentation section</a>.
</p>
</div>
</div>
)
}
public onChartLoad(args: ILoadedEventArgs): void {
let chart: Element = document.getElementById('charts');
chart.setAttribute('title', '');
};
public load(args: ILoadedEventArgs): void {
let selectedTheme: string = location.hash.split('/')[1];
selectedTheme = selectedTheme ? selectedTheme : 'Material';
args.chart.theme = (selectedTheme.charAt(0).toUpperCase() + selectedTheme.slice(1)) as ChartTheme;
};
}