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 dataset1 = anychart.data.set([
6
{id: 'AU.CT', value: 15, title: 'Australian Capital Territory'},
7
{id: 'AU.VI', value: 23, title: 'Victoria'},
8
{id: 'AU.WA', value: 86, title: 'Western Australia'},
9
{id: 'AU.QL', value: 16, title: 'Queensland'}
10
]);
11
12
var dataset2 = anychart.data.set([
13
{id: 'AU.NS', value: 32, title: 'New South Wales'},
14
{id: 'AU.NT', value: 64, title: 'Northern Territory'},
15
{id: 'AU.TS', value: 28, title: 'Tasmania'},
16
{id: 'AU.SA', value: 45, title: 'South Australian'}
17
]);
18
19
var map = anychart.map();
20
map.geoData(anychart.maps.australia);
21
map.legend(true);
22
23
var series1 = map.choropleth(dataset1);
24
25
// Get legend item.
26
var seriesLegendItem = series1.legendItem();
27
seriesLegendItem.iconType('circle');
28
seriesLegendItem.text('Custom legend item');
29
30
map.choropleth(dataset2);
31
32
map.title('Get and modify legend item');
33
map.container('container');
34
map.draw();
35
});