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', '100%', '100%');
3
4
var scale = anychart.scales.linear();
5
scale.minimum(5);
6
scale.maximum(40);
7
8
var firstChart = anychart.sparkline([
9
{x: 1, y: 5},
10
{x: 5, y: 50},
11
{x: 16, y: 10},
12
{x: 20, y: 60},
13
{x: 25, y: 15},
14
{x: 30, y: 40}
15
]);
16
17
// Set X scale.
18
firstChart.xScale(scale);
19
firstChart.bounds(0, '5%', '100%', '5%');
20
firstChart.container(stage);
21
firstChart.draw();
22
23
var secondChart = anychart.sparkline([
24
{x: 9, y: 25},
25
{x: 10, y: 5},
26
{x: 13, y: 30},
27
{x: 18, y: 10},
28
{x: 20, y: 35},
29
{x: 35, y: 60}
30
]);
31
32
secondChart.seriesType('column');
33
34
// Set X-scale.
35
secondChart.xScale(scale);
36
secondChart.bounds(0, '10%', '100%', '5%');
37
secondChart.container(stage);
38
secondChart.draw();
39
40
var customTitle = anychart.standalones.title();
41
customTitle.text('Set X scale');
42
customTitle.orientation('top');
43
customTitle.container(stage);
44
customTitle.draw();
45
});