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 pathrow-json-binding.tsx
More file actions
119 lines (116 loc) · 5.89 KB
/
row-json-binding.tsx
File metadata and controls
119 lines (116 loc) · 5.89 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
import * as React from "react";
import * as ReactDOM from "react-dom";
import { HeatMapComponent, Legend, Tooltip, ILoadedEventArgs, HeatMapTheme, Inject } from '@syncfusion/ej2-react-heatmap';
import { Adaptor, ITooltipEventArgs } from '@syncfusion/ej2-react-heatmap';
import { SampleBase } from '../common/sample-base';
const SAMPLE_CSS: any = `
#control-container {
padding: 0px !important;
}
#source{
float: right; margin-right: 10p
}`;
/**
* Heatmap JSON data binding sample
*/
export class JsonRow extends SampleBase<{}, {}> {
private jsonTableData: Object = [
{ 'Region': 'USA', '2000': 93, '2004': 101, '2008': 112, '2012': 103, '2016': 121 },
{ 'Region': 'GBR', '2000': 28, '2004': 30, '2008': 49, '2012': 65, '2016': 67 },
{ 'Region': 'China', '2000': 58, '2004': 63, '2008': 100, '2012': 91, '2016': 70 },
{ 'Region': 'Russia', '2000': 89, '2004': 90, '2008': 60, '2012': 69, '2016': 55 },
{ 'Region': 'Germany', '2000': 56, '2004': 49, '2008': 41, '2012': 44, '2016': 42 },
{ 'Region': 'Japan', '2000': 18, '2004': 37, '2008': 25, '2012': 38, '2016': 41 },
{ 'Region': 'France', '2000': 38, '2004': 33, '2008': 43, '2012': 35, '2016': 42 },
{ 'Region': 'KOR', '2000': 28, '2004': 30, '2008': 32, '2012': 30, '2016': 21 },
{ 'Region': 'Italy', '2000': 34, '2004': 32, '2008': 27, '2012': 28, '2016': 28 }];
render() {
return (
<div className='control-pane'>
<style>
{SAMPLE_CSS}
</style>
<div className='control-section'>
<HeatMapComponent id='heatmap-container'
titleSettings={{
text: 'Olympic Medal Achievements of most Successful Countries',
textStyle: {
size: '15px',
fontWeight: '500',
fontStyle: 'Normal',
fontFamily: 'Segoe UI'
}
}}
xAxis={{
labels: ['China', 'France', 'GBR', 'Germany', 'Italy', 'Japan', 'KOR', 'Russia', 'USA'],
labelRotation: 45,
labelIntersectAction: 'None',
}}
yAxis={{
title: { text: 'Olympic Year' },
labels: ['2000', '2004', '2008', '2012', '2016'],
}}
dataSource={{
data: this.jsonTableData,
isJsonData: true,
adaptorType: 'Table',
xDataMapping: 'Region',
}}
paletteSettings={{
palette: [{ color: '#F0C27B' },
{ color: '#4B1248' }
]
}}
cellSettings={{
border: {
width: 1,
radius: 4,
color: 'white'
}
}}
load={this.load.bind(this)}
tooltipRender={this.tooltipTemplate}>
<Inject services={[Legend, Tooltip, Adaptor]} />
</HeatMapComponent>
</div>
<div id="source">Source:
<a href="https://en.wikipedia.org/wiki/2016_Summer_Olympics_medal_table" target="_blank">https://en.wikipedia.org/</a>
</div>
<div id="action-description">
<p>
This sample visualizes the overall Olympic medals won by the countries in all the summer Olympic
events from the year 2000 to 2016.
</p>
</div>
<div id="description">
<p>
In this example, you can see how to bind JSON data and configure the Heatmap using the data adaptor support.
You can bind the JSON data with information for each row to the Heatmap using <code>isJsonData</code> and by
defining the <code>adaptorType</code> properties. In row JSON data, the row header is mapped using the
<code>xDataMapping</code>.
</p>
<p>
Tooltip is enabled in this example, to see the tooltip in action, hover a point or tap on a point in
touch enabled devices.
</p>
<br></br>
<p> <strong>Injecting Module</strong></p>
<p>
Heatmap component features are segregated into individual feature-wise modules. To use data adaptor support,
we need to inject <code>Adaptor</code> module using <code>Heatmap.Inject(Adaptor)</code> method, to use a tooltip,
inject the <code>Tooltip</code> module using the <code>Heatmap.Inject(Tooltip)</code> method, and use a legend by
injecting the <code>Legend</code> module using the <code>Heatmap.Inject(Legend)</code> method.
</p>
</div>
</div >
);
}
public load(args: ILoadedEventArgs): void {
let selectedTheme: string = location.hash.split('/')[1];
selectedTheme = selectedTheme ? selectedTheme : 'Material';
args.heatmap.theme = (selectedTheme.charAt(0).toUpperCase() + selectedTheme.slice(1)) as HeatMapTheme;
};
private tooltipTemplate(args: ITooltipEventArgs): void {
args.content = [args.yLabel + ' | ' + args.xLabel + ' : ' + args.value + ' medals'];
};
}