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 pathaxis-types.tsx
More file actions
150 lines (149 loc) · 10.1 KB
/
axis-types.tsx
File metadata and controls
150 lines (149 loc) · 10.1 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
/**
* Axis types samples for sparkline
*/
import * as React from "react";
import * as ReactDOM from "react-dom";
import { SparklineComponent, Inject, SparklineTheme, ISparklineLoadedEventArgs, SparklineTooltip } from '@syncfusion/ej2-react-charts';
import { SampleBase } from '../common/sample-base';
const SAMPLE_CSS = `
.control-fluid {
padding: 0px !important;
}`;
const tableWidth = { width: '100%' };
const padding10 = { padding: '10px' };
export class Axis extends SampleBase<{}, {}> {
private sparklineInstance: SparklineComponent;
public load(args: ISparklineLoadedEventArgs): void {
let theme: string = location.hash.split('/')[1];
theme = theme ? theme : 'Material';
args.sparkline.theme = (theme.charAt(0).toUpperCase() + theme.slice(1)) as SparklineTheme;
}
render() {
return (
<div className='control-pane'>
<style>
{SAMPLE_CSS}
</style>
<div className='control-section'>
<div id="spark-container" className="row">
<div className="cols-sample-area">
<table style={tableWidth}>
<tbody>
<tr>
<td style={{ "text-align": "center", "font-size": "14px", "font-weight": "600", "font-family": "Roboto" }}>
<div>Mean working hours for a month</div>
<div><i>(DateTime axis)</i></div>
</td>
<td style={padding10}>
<SparklineComponent load={this.load.bind(this)} id='spark1-container'
height='100px' width='170px' lineWidth={1} type='Column' valueType='DateTime'
fill='#3C78EF'
tooltipSettings={{
visible: true, format: '${xDate} : ${yval}hrs',
}}
dataSource={[
{ xDate: new Date(2018, 0, 1), x: 0, yval: 4 },
{ xDate: new Date(2018, 0, 2), x: 1, yval: 4.5 },
{ xDate: new Date(2018, 0, 3), x: 2, yval: 8 },
{ xDate: new Date(2018, 0, 4), x: 3, yval: 7 },
{ xDate: new Date(2018, 0, 5), x: 4, yval: 6 },
{ xDate: new Date(2018, 0, 8), x: 5, yval: 8 },
{ xDate: new Date(2018, 0, 9), x: 6, yval: 8 },
{ xDate: new Date(2018, 0, 10), x: 7, yval: 6.5 },
{ xDate: new Date(2018, 0, 11), x: 8, yval: 4 },
{ xDate: new Date(2018, 0, 12), x: 9, yval: 5.5 },
{ xDate: new Date(2018, 0, 15), x: 10, yval: 8 },
{ xDate: new Date(2018, 0, 16), x: 11, yval: 6 },
{ xDate: new Date(2018, 0, 17), x: 12, yval: 6.5 },
{ xDate: new Date(2018, 0, 18), x: 13, yval: 7.5 },
{ xDate: new Date(2018, 0, 19), x: 14, yval: 7.5 },
{ xDate: new Date(2018, 0, 22), x: 15, yval: 4 },
{ xDate: new Date(2018, 0, 23), x: 16, yval: 8 },
{ xDate: new Date(2018, 0, 24), x: 17, yval: 6 },
{ xDate: new Date(2018, 0, 25), x: 18, yval: 7.5 },
{ xDate: new Date(2018, 0, 26), x: 19, yval: 4.5 },
{ xDate: new Date(2018, 0, 29), x: 20, yval: 6 },
{ xDate: new Date(2018, 0, 30), x: 21, yval: 5 },
{ xDate: new Date(2018, 0, 31), x: 22, yval: 7 }
]}
xName='xDate' yName='yval'>
<Inject services={[SparklineTooltip]} />
</SparklineComponent>
</td>
</tr>
<tr>
<td style={{ "text-align": "center", "font-size": "14px", "font-weight": "600", "font-family": "Roboto" }}>
<div>Percentage of the students in a class</div>
<div><i>(Category axis)</i></div>
</td>
<td style={padding10}>
<SparklineComponent load={this.load.bind(this)} id='spark2-container'
height='100px' width='170px' lineWidth={1} type='Column' valueType='Category'
fill='#3C78EF'
tooltipSettings={{
visible: true, format: '${xval} : ${yval}%',
}}
dataSource={[
{ x: 0, xval: 'Robert', yval: 60 },
{ x: 1, xval: 'Andrew', yval: 65 },
{ x: 2, xval: 'Suyama', yval: 70 },
{ x: 3, xval: 'Michael', yval: 80 },
{ x: 4, xval: 'Janet', yval: 55 },
{ x: 5, xval: 'Davolio', yval: 90 },
{ x: 6, xval: 'Fuller', yval: 75 },
{ x: 7, xval: 'Nancy', yval: 85 },
{ x: 8, xval: 'Margaret', yval: 77 },
{ x: 9, xval: 'Steven', yval: 68 },
{ x: 10, xval: 'Laura', yval: 96 },
{ x: 11, xval: 'Elizabeth', yval: 57 }
]}
xName='xval' yName='yval'>
<Inject services={[SparklineTooltip]} />
</SparklineComponent>
</td>
</tr>
<tr>
<td style={{ "text-align": "center", "font-size": "14px", "font-weight": "600", "font-family": "Roboto" }}>
<div>Expenditure details of various trips</div>
<div><i>(Numeric axis)</i></div>
</td>
<td style={padding10}>
<SparklineComponent load={this.load.bind(this)} id='spark3-container'
height='100px' width='170px' lineWidth={1} type='Column' valueType='Numeric'
fill='#3C78EF'
tooltipSettings={{
visible: true, format: '${x} : $${yval}',
}}
dataSource={[
{ x: 1, xval: 2010, yval: 190 },
{ x: 2, xval: 2011, yval: 165 },
{ x: 3, xval: 2012, yval: 158 },
{ x: 4, xval: 2013, yval: 175 },
{ x: 5, xval: 2014, yval: 200 },
{ x: 6, xval: 2015, yval: 180 },
{ x: 7, xval: 2016, yval: 210 }
]}
xName='x' yName='yval'>
<Inject services={[SparklineTooltip]} />
</SparklineComponent>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div id="action-description">
<p>
This sample depicts the various types of axis value types available in sparkline.
</p>
</div>
<div id="description">
<p>
In this example, you can see the sparklines with various axis value types such as date-time, category, and numeric. Tooltip is enabled in this example. To see the tooltip in action, hover the mouse over the data points or tap on a data point in touch enabled devices.
</p>
</div>
</div>
)
}
}