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 pathheatmap.tsx
More file actions
123 lines (121 loc) · 5.39 KB
/
heatmap.tsx
File metadata and controls
123 lines (121 loc) · 5.39 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
/**
* Projection sample
*/
import * as React from "react";
import * as ReactDOM from "react-dom";
import { MapAjax } from '@syncfusion/ej2-maps';
import {
MapsComponent, Inject, ILoadedEventArgs, MapsTheme, LayersDirective, LayerDirective,
ProjectionType, MapsTooltip, Legend, Marker, MarkersDirective, MarkerDirective
} from '@syncfusion/ej2-react-maps';
import { Browser } from '@syncfusion/ej2-base';
import { SampleBase } from '../common/sample-base';
const SAMPLE_CSS = `
.control-fluid {
padding: 0px !important;
}`;
let colormapping: object[] = [{
from: 60000, to: 400000, color: '#9fdfdf', label: '<0.4M'
},
{
from: 400000, to: 10000000, color: '#79d2d2', label: '0.4-10M'
},
{
from: 10000000, to: 20000000, color: '#53C6C6', label: '10-20M'
},
{
from: 20000000, to: 70000000, color: '#39acac', label: '20-70M'
},
{
from: 70000000, to: 100000000, color: '#339999', label: '70-100M'
},
{
from: 100000000, to: 200000000, color: '#2d8686', label: '>100M'
}
];
export class HeatMaps extends SampleBase<{}, {}> {
private mapInstance: MapsComponent;
render() {
return (
<div className='control-pane'>
<style>
{SAMPLE_CSS}
</style>
<div className='control-section row'>
<div className='col-md-12'>
<MapsComponent id="maps" loaded={this.onMapsLoad.bind(this)} load={this.load} ref={m => this.mapInstance = m}
useGroupingSeparator = {true}
format = {"n"}
zoomSettings={{
enable: false
}}
legendSettings={{
visible: true,
mode: 'Interactive',
position: 'Bottom',
height: '10',
width: '350',
alignment: 'Center',
labelDisplayMode: 'Trim'
}}
titleSettings={{
text: "State wise India's population - 2011",
textStyle: {
size: '16px'
}
}}
>
<Inject services={[Marker, MapsTooltip, Legend]} />
<LayersDirective>
<LayerDirective shapeData={new MapAjax(location.origin + location.pathname + 'src/maps/map-data/india.json')}
shapePropertyPath='NAME_1'
shapeDataPath='Name'
dataSource={new MapAjax(location.origin + location.pathname + 'src/maps/map-data/heatmap-datasource.json')}
tooltipSettings={{
visible: true,
valuePath:'population',
format: 'State: ${Name} <br> Population: ${population}'
}}
shapeSettings={{
border: {
width: 0.2,
color: 'white'
},
colorValuePath: 'population',
colorMapping:colormapping
}}
>
</LayerDirective>
</LayersDirective>
</MapsComponent>
</div>
</div>
<div style={{float: 'right', marginright: '10px'}}>Source:
<a href="https://en.wikipedia.org/wiki/List_of_states_and_union_territories_of_India_by_population" target="_blank">en.wikipedia.org</a>
</div>
<div id="action-description">
<p>
This sample visualizes the state wise population of India in the year 2011. Color for each state will be applied based on its value.
</p>
</div>
<div id="description">
<p>
In this example, you can see how to apply the desired colors for the shapes, if its value is within the specified range using the ColorMapping property. Also, the interactive legend has been placed at the bottom of the map.
</p>
<p>
Tooltip is enabled in this example. To see the tooltip in action, hover the mouse over a shape or tap a shape in touch enabled devices.
</p>
</div>
</div>
)
}
public onMapsLoad(args: ILoadedEventArgs): void {
let maps: Element = document.getElementById('maps');
maps.setAttribute('title', '');
};
public load(args: ILoadedEventArgs): void {
let selectedTheme: string = location.hash.split('/')[1];
selectedTheme = selectedTheme ? selectedTheme : 'Material';
args.maps.theme = (selectedTheme.charAt(0).toUpperCase() + selectedTheme.slice(1)) as MapsTheme;
};
}