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 dataTable = anychart.data.table();
3
dataTable.addData(get_dji_daily_short_data());
4
5
var firstMapping = dataTable.mapAs({value: 1});
6
var secondMapping = dataTable.mapAs({value: 5});
7
8
var chart = anychart.stock();
9
chart.padding(10, 10, 10, 50);
10
11
var firstPlot = chart.plot(0);
12
firstPlot.line(firstMapping);
13
firstPlot.line(secondMapping);
14
15
var firstPlotYScale = firstPlot.yScale();
16
firstPlotYScale.comparisonMode("percent");
17
18
// Set date for the changes zero of the series.
19
firstPlotYScale.compareWith(anychart.enums.ScaleCompareWithMode.SERIES_START);
20
21
var secondPlot = chart.plot(1);
22
secondPlot.line(firstMapping);
23
secondPlot.line(secondMapping);
24
25
var secondPlotYScale = secondPlot.yScale();
26
secondPlotYScale.comparisonMode("percent");
27
28
// Set date for first visible point.
29
secondPlotYScale.compareWith(anychart.enums.ScaleCompareWithMode.FIRST_VISIBLE);
30
31
var thirdPlot = chart.plot(2);
32
thirdPlot.line(firstMapping);
33
thirdPlot.line(secondMapping);
34
35
var thirdPlotYScale = thirdPlot.yScale();
36
thirdPlotYScale.comparisonMode("percent");
37
38
// Set custom date.
39
thirdPlotYScale.compareWith(1209081600000);
40
41
chart.title("First plot: compare scale with series start \n Second plot: compare scale with first visible point \n" +
42
"Third plot: compare scale with custom date");
43
chart.container("container");
44
chart.draw();
45
});