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 firstDataSet = 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 secondDataSet = 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.NT", value: 64, title: "Northern Territory"},
24
{id: "AU.TS", value: 28, title: "Tasmania"},
25
{id: "AU.SA", value: 45, title: "South Australian"}
26
]);
27
28
var firstDataSetForSeries = firstDataSet.mapAs({id: "id"});
29
30
var firstAustraliaMap = anychart.map();
31
firstAustraliaMap.bounds(0, 0, "50%", "100%");
32
firstAustraliaMap.geoData(anychart.maps.australia);
33
34
var series = firstAustraliaMap.choropleth(firstDataSetForSeries);
35
series.geoIdField("code_hasc");
36
series.selectHatchFill("backwardDiagonal", "#9E9E9E", 1.5, 50);
37
38
firstAustraliaMap.container(stage);
39
firstAustraliaMap.draw();
40
41
var secondDataSetForSeries = secondDataSet.mapAs({id: "id"});
42
43
var secondAustraliaMap = anychart.map();
44
secondAustraliaMap.bounds("50%", 0, "50%", "100%");
45
secondAustraliaMap.geoData(anychart.maps.australia);
46
47
var secondSeries = secondAustraliaMap.choropleth(secondDataSetForSeries);
48
secondSeries.geoIdField("code_hasc");
49
50
var color = anychart.scales.linearColor("#8BC34A");
51
secondSeries.colorScale(color);
52
53
// Get select hatch fill.
54
var selectHatchFill = series.selectHatchFill();
55
56
secondSeries.selectHatchFill(selectHatchFill);
57
58
// Selects series.
59
series.select();
60
secondSeries.select();
61
62
secondAustraliaMap.container(stage);
63
secondAustraliaMap.draw();
64
65
var title = anychart.standalones.title();
66
title.text("Get and use select hatch fill");
67
title.container(stage);
68
title.draw();
69
});