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("Adjust labels");
18
// create new series
19
seatMapSeries = chart.choropleth();
20
// load data
21
seatMapSeries.data([
22
{id: "Hall", value: "720", info: "30\' 0\" x 24\'0\"", sq: "720 sq. ft."},
23
{id: "Room2", value: "165", info: "15\' 0\" x 11\'0\"", sq: "165 sq. ft."},
24
{id: "WC", value: "49", info: "7\' 0\" x 7\'0\"", sq: "49 sq. ft."},
25
{id: "Room1", value: "143", info: "11\' 0\" x 13\'0\"", sq: "143 sq. ft."},
26
{id: "Kitchen", value: "208", info: "13\' 0\" x 16\'0\"", sq: "208 sq. ft."}
27
]);
28
29
// set the filling color
30
seatMapSeries.fill("white");
31
// allow labels to overlap each other
32
seatMapSeries.overlapMode("allow-overlap");
33
seatMapSeries.tooltip(false);
34
35
labels = seatMapSeries.labels();
36
// enable labels and adjust them
37
labels.enabled(true);
38
seatMapSeries.labels({fontSize: 10, background: {fill: 'green .3'}});
39
labels.format("{%id} \n{%info} \n{%sq}");
40
labels.offsetY(-13);
41
42
// load svg-file without elements with no values
43
chart.unboundRegions("hide");
44
45
// set container id for the chart
46
chart.container("container");
47
// initiate chart drawing
48
chart.draw();
49
};