HTMLcopy
1
<div id="container"></div>
CSScopy
8
1
html,
2
body,
3
#container {
4
width: 100%;
5
height: 100%;
6
margin: 0;
7
padding: 0;
8
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
var stage = acgraph.create('container');
3
4
// The data that have been used for this sample can be taken from the CDN
5
// https://cdn.anychart.com/svg-data/seat-map/zimbabwe_with_flag.svg
6
$('#container').append(
7
'<div class="seat-map-title">' +
8
'<h1>Using SVG as GeoData</h1>' +
9
'<p>(draw chart in <a href="https://cdn.anychart.com/svg-data/seat-map/zimbabwe_with_flag.svg"' +
10
'target="_blank">SVG data</a>)</p></div>'
11
);
12
13
$.ajax({
14
type: 'GET',
15
url:
16
'https://cdn.anychart.com/svg-data/seat-map/' +
17
'zimbabwe_with_flag.svg',
18
success: function (data) {
19
var dataSet = anychart.data.set([
20
{ id: 'ZW.MC', value: 9 },
21
{ id: 'ZW.HA', value: 25 },
22
{ id: 'ZW.MN', value: 43 },
23
{ id: 'ZW.MI', value: 7 },
24
{ id: 'ZW.ME', value: 23 },
25
{ id: 'ZW.MA', value: 59 },
26
{ id: 'ZW.MS', value: 11 },
27
{ id: 'ZW.BU', value: 22 },
28
{ id: 'ZW.MV', value: 17 },
29
{ id: 'ZW.MW', value: 12 }
30
]);
31
32
var mapping = dataSet.mapAs({ id: 'id' });
33
34
// create map
35
var map = anychart.map();
36
// set svg data
37
map
38
.geoData(data)
39
.padding([105, 0, 20, 0])
40
// load svg-file how it looked(colors stroke/fill except
41
// for elements of series)
42
.unboundRegions('as-is');
43
44
// create choropleth series for map
45
var series = map.choropleth(mapping);
46
47
var scale = anychart.scales.ordinalColor([
48
{ less: 10 },
49
{ from: 10, to: 20 },
50
{ from: 20, to: 50 },
51
{ greater: 50 }
52
]);
53
scale.colors(['#81d4fa', '#29b6f6', '#0288d1', '#01579b']);
54
55
// set color for choropleth series for map
56
series.colorScale(scale);
57
58
// set container for the chart
59
map.container(stage);
60
// initiate chart drawing
61
map.draw();
62
}
63
});
64
});