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
var stage = anychart.graphics.create('container');
3
4
var chart = anychart.scatter();
5
chart.line([
6
{x: 1, value: 0},
7
{x: 2, value: 20},
8
{x: 3, value: 10},
9
{x: 4, value: 30},
10
{x: 5, value: 20},
11
{x: 6, value: 40},
12
{x: 7, value: 30},
13
{x: 8, value: 50},
14
{x: 9, value: 40},
15
{x: 1, value: 0}
16
]);
17
chart.xGrid(true).yGrid(true);
18
chart.bounds(0, 0, '50%', '100%');
19
chart.title('Serialize chart node to XML');
20
chart.container(stage);
21
chart.draw();
22
23
// Returns chart config as XMLNode.
24
var xml = chart.toXml(true);
25
26
var chartFromXml = anychart.fromXml(xml);
27
chartFromXml.bounds('50%', 0, '50%', '100%');
28
chartFromXml.title('Creates chart from XML node');
29
chartFromXml.container(stage);
30
chartFromXml.draw();
31
});