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 pathchart-performance.tsx
More file actions
101 lines (99 loc) · 4.6 KB
/
Copy pathchart-performance.tsx
File metadata and controls
101 lines (99 loc) · 4.6 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
/**
* Sample for Chart performance
*/
import * as React from "react";
import * as ReactDOM from "react-dom";
import { PropertyPane } from '../common/property-pane';
import { ButtonComponent } from '@syncfusion/ej2-react-buttons';
import {
ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
LineSeries, Legend, ILoadedEventArgs, ChartTheme
} from '@syncfusion/ej2-react-charts';
import { EmitType } from '@syncfusion/ej2-base';
import { SampleBase } from '../common/sample-base';
export class Performance extends SampleBase<{}, {}> {
private chart: ChartComponent;
private loaded: EmitType<ILoadedEventArgs>;
private dt1: number = 0;
public change(): void {
let series1: Object[] = [];
let point1: Object;
let value: number = 0;
let i: number;
for (i = 0; i < 100000; i++) {
value += (Math.random() * 10 - 5);
point1 = { x: i, y: value };
series1.push(point1);
}
this.dt1 = new Date().getTime();
this.chart.series[0].animation.enable = false;
this.chart.series[0].dataSource = series1;
this.chart.series[0].xName = 'x';
this.chart.series[0].yName = 'y';
this.chart.refresh();
}
public onChartLoad(args: ILoadedEventArgs): void {
let dt2: number;
dt2 = new Date().getTime();
if (this.dt1) {
document.getElementById('performanceTime').innerHTML = (dt2 - this.dt1) + 'ms';
}
this.dt1 = 0;
};
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;
};
render() {
return (
<div className='control-pane'>
<div className='control-section row'>
<div className='col-lg-9'>
<ChartComponent id='charts' ref={chart => this.chart = chart} loaded={this.onChartLoad.bind(this)}
primaryXAxis={{
majorGridLines: { color: 'transparent' }
}} load={this.load.bind(this)} legendSettings={{ visible: false }}>
<Inject services={[LineSeries, Legend]} />
<SeriesCollectionDirective>
<SeriesDirective name='Series1' type='Line' animation={{ enable: false }}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
</div>
<div className='col-lg-3 property-section'>
<PropertyPane title='Properties'>
<table id='property' title='Properties' className='property-panel-table' style={{ width: '100%' }}>
<tr style={{ height: "50px" }}>
<td style={{ width: '50%' }}>
<ButtonComponent cssClass='e-info' onClick={this.change.bind(this)} isPrimary={true} style={{ textTransform: 'None', width: 140, textAlign: 'center' }}>Load 100K Points</ButtonComponent>
</td>
</tr>
<tr style={{ height: "50px" }}>
<td style={{ width: '30%' }}>
<div>Time Taken</div>
</td>
<td style={{ width: '70%' }}>
<div>
<span id="performanceTime">0ms</span>
</div>
</td>
</tr>
</table>
</PropertyPane>
</div>
</div>
<div id="action-description">
<p>
This sample demonstrates the performance of EJ2 chart to render 100K points.
</p>
</div>
<div id="description">
<p>
Chart includes several data rendering optimizations to achieve the best possible performance when plotting large volumes of data as well as handling high frequency real-time data.In this demo, chart is rendered with 100K points.
</p>
</div>
</div>
)
}
}