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
$.ajax({
3
type: "GET",
4
url: "https://static.anychart.com/images/docs/seat_map/house.svg",
5
success: function (svgData) {
6
createSeatMap(svgData);
7
}
8
});
9
});
10
11
function createSeatMap(svg){
12
// create a new seat map
13
var chart = anychart.seatMap();
14
// load SVG data
15
chart.geoData(svg);
16
// set the title
17
chart.title("Set the fill and stroke original colors through coloring methods");
18
// create new series
19
seatMapSeries = chart.choropleth();
20
// load data
21
seatMapSeries.data([
22
{id: "Hall", value: "720"},
23
{id: "Room2", value: "165"},
24
{id: "WC", value: "49"},
25
{id: "Room1", value: "143"},
26
{id: "Kitchen", value: "208"}
27
]);
28
29
// load svg-file how it looked(colors stroke/fill except for elements of series)
30
chart.unboundRegions("as-is");
31
32
// sets series fill
33
seatMapSeries.fill(function () {
34
var attrs = this.attributes;
35
if (attrs) return attrs.fill;
36
});
37
38
// sets series stroke
39
seatMapSeries.stroke(function () {
40
var attrs = this.attributes;
41
// if the stroke attribute exists in the SVG file then color it with a color set in the document
42
return attrs ? attrs.stroke : this.sourceColor;
43
});
44
45
// set container id for the chart
46
chart.container("container");
47
// initiate chart drawing
48
chart.draw();
49
};