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.xScale(anychart.scales.dateTime());
6
chart.xScale().minimum(Date.UTC(2015, 5, 21));
7
chart.xScale().maximum(Date.UTC(2015, 5, 29));
8
chart.line([
9
{x: Date.UTC(2015, 5, 22), value: 26.85},
10
{x: Date.UTC(2015, 5, 23), value: 27.88},
11
{x: Date.UTC(2015, 5, 24), value: 25.86},
12
{x: Date.UTC(2015, 5, 25), value: 29.88},
13
{x: Date.UTC(2015, 5, 26), value: 25.87},
14
{x: Date.UTC(2015, 5, 27), value: 24.89},
15
{x: Date.UTC(2015, 5, 28), value: 26.88},
16
{x: Date.UTC(2015, 5, 29), value: 23.89}
17
]);
18
chart.title('Get and use plot bounds object');
19
chart.container(stage);
20
chart.draw();
21
22
// Get plot bounds.
23
var bounds = chart.getPlotBounds();
24
25
var customBackground = anychart.standalones.background();
26
customBackground.fill('#BDBDBD 0.2');
27
customBackground.parentBounds(bounds);
28
customBackground.container(stage);
29
customBackground.draw();
30
});