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
3
// create a data table
4
var dataTable = anychart.data.table();
5
dataTable.addData([
6
['2016-12-24', 511.53, 514.98, 505.79, 506.40],
7
['2016-12-25', 512.53, 514.88, 505.69, 507.34],
8
['2016-12-26', 511.83, 514.98, 505.59, 506.23],
9
['2016-12-27', 511.22, 515.30, 505.49, 506.47],
10
['2016-12-28', 510.35, 515.72, 505.23, 505.80],
11
['2016-12-29', 510.53, 515.86, 505.38, 508.25],
12
['2016-12-30', 511.43, 515.98, 505.66, 507.45],
13
['2016-12-31', 511.50, 515.33, 505.99, 507.98],
14
['2017-01-01', 511.32, 514.29, 505.99, 506.37],
15
['2017-01-02', 511.70, 514.87, 506.18, 506.75],
16
['2017-01-03', 512.30, 514.78, 505.87, 508.67],
17
['2017-01-04', 512.50, 514.77, 505.83, 508.35],
18
['2017-01-05', 511.53, 516.18, 505.91, 509.42],
19
['2017-01-06', 511.13, 516.01, 506.00, 509.26],
20
['2017-01-07', 510.93, 516.07, 506.00, 510.99],
21
['2017-01-08', 510.88, 515.93, 505.22, 509.95],
22
['2017-01-09', 509.12, 515.97, 505.15, 510.12],
23
['2017-01-10', 508.53, 516.13, 505.66, 510.42],
24
['2017-01-11', 508.90, 516.24, 505.73, 510.40]
25
]);
26
27
// map the data
28
mapping = dataTable.mapAs(
29
{open: 1, high: 2, low: 3, close: 4, value: 4}
30
);
31
32
// create a stock chart
33
var chart = anychart.stock();
34
35
// create two plots
36
var plot_1 = chart.plot(0);
37
var plot_2 = chart.plot(1);
38
39
// create two series: line and ohlc
40
plot_1.line(mapping);
41
plot_2.ohlc(mapping);
42
43
/* configure the strokes of the crosshair
44
on the first plot */
45
plot_1.crosshair().xStroke("#00bfa5", 1.5, "10 5", "round");
46
plot_1.crosshair().yStroke("#00bfa5", 1.5);
47
48
/* configure the strokes of the crosshair
49
on the second plot */
50
plot_2.crosshair().xStroke(null);
51
plot_2.crosshair().yStroke("#00bfa5", 1.5);
52
53
// set the chart title
54
chart.title("Crosshair: Appearance");
55
56
// set the container id
57
chart.container("container");
58
59
// initiate drawing the chart
60
chart.draw();
61
});