HTMLcopy
1
<div id="container"></div>
CSScopy
6
1
html, body, #container {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
// This sample uses 3rd party Proj4js JavaScript library to transform coordinates
3
// See https://docs.anychart.com/Maps/Map_Projections to learn more.
4
5
var stage = anychart.graphics.create("container");
6
7
var dataset1 = anychart.data.set([
8
{id: 'AU.CT', value: 15, title: 'Australian Capital Territory'},
9
{id: 'AU.VI', value: 23, title: 'Victoria'},
10
{id: 'AU.WA', value: 86, title: 'Western Australia'},
11
{id: 'AU.QL', value: 16, title: 'Queensland'},
12
{id: 'AU.NS', value: 32, title: 'New South Wales'},
13
{id: 'AU.NT', value: 64, title: 'Northern Territory'},
14
{id: 'AU.TS', value: 28, title: 'Tasmania'},
15
{id: 'AU.SA', value: 45, title: 'South Australian'}
16
]);
17
18
var dataset2 = anychart.data.set([
19
{id: 'AU.CT', value: 15, title: 'Australian Capital Territory'},
20
{id: 'AU.VI', value: 23, title: 'Victoria'},
21
{id: 'AU.WA', value: 86, title: 'Western Australia'},
22
{id: 'AU.QL', value: 16, title: 'Queensland'},
23
{id: 'AU.NS', value: 32, title: 'New South Wales'},
24
{id: 'AU.NT', value: 64, title: 'Northern Territory'},
25
{id: 'AU.TS', value: 28, title: 'Tasmania'},
26
{id: 'AU.SA', value: 45, title: 'South Australian'}
27
]);
28
29
var map1 = anychart.map();
30
map1.bounds(0, 0, '50%', '100%');
31
map1.geoData(anychart.maps.australia);
32
33
var series1 = map1.choropleth(dataset1);
34
series1.hatchFill('backward-diagonal', '#FFFFFF', 1.5, 50);
35
36
map1.container(stage);
37
map1.draw();
38
39
var map2 = anychart.map();
40
map2.bounds('50%', 0, '50%', '100%');
41
map2.geoData(anychart.maps.australia);
42
43
var series2 = map2.choropleth(dataset2);
44
45
var color = anychart.scales.linearColor('#8BC34A');
46
series2.colorScale(color);
47
48
// Get hatch fill.
49
var hatchFill = series1.hatchFill();
50
51
series2.hatchFill(hatchFill);
52
53
map2.container(stage);
54
map2.draw();
55
56
var title = anychart.standalones.title();
57
title.text('Get and use hatch fill');
58
title.container(stage);
59
title.draw();
60
});