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
3
// set the data to visualize in a mosaic plot
4
let data = {
5
header: ['#', '2006', '2009', '2012', '2015', '2018', '2021'],
6
rows: [
7
['18–29', 41, 70, 81, 90, 88, 84],
8
['30–49', 6, 42, 64, 77, 78, 81],
9
['50–64', 3, 20, 39, 51, 64, 73],
10
['65+', 0, 5, 16, 35, 37, 45]
11
]
12
};
13
14
// create a mosaic plot
15
let chart = anychart.mosaic();
16
17
// load the data to the mosaic plot
18
chart.data(data);
19
20
// set the mosaic plot title
21
chart.title("Social Media Use in U.S. by Age");
22
23
// set the mosaic plot container element id
24
chart.container('container');
25
26
// draw the resulting mosaic plot
27
chart.draw();
28
29
});