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
anychart.data.loadJsonFile('https://gist.githubusercontent.com/awanshrestha/9d0f4c864817d5ee043126f63f1f4d02/raw/91cb71ac4159ce86bbe2eb204c190f1e9ce43ba6/surface-test.json',
3
function (data) {
4
// pre-process the data
5
var result = [];
6
for (var x = 0; x < data.x.length; x++) {
7
for (var y = 0; y < data.y.length; y++) {
8
result.push([x, data.y[y], data.z[x][y]]);
9
}
10
}
11
12
// create a surface chart
13
var chart = anychart.surface(result);
14
15
// set the x-axis label format
16
chart
17
.xAxis()
18
.labels()
19
.format(function () {
20
return data.x[Math.round(this.value)];
21
});
22
23
// set the x-scale maximum
24
chart.xScale().maximum(data.x.length - 1);
25
26
// set the chart paddings
27
chart.padding(50, 50, 50, 75);
28
29
// set the default chart rotation by the y-axis
30
chart.rotationY(40);
31
// set the default chart rotation by the z-axis
32
chart.rotationZ(130);
33
34
// set the chart title
35
chart.title('Population Growth of Top 50 Most Populous Countries Over Past 50 Years');
36
37
// set the container id for the chart
38
chart.container('container');
39
40
// initiate the visualization
41
chart.draw();
42
}
43
);
44
});