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 chart
4
var chart = anychart.financial();
5
6
// set the interactivity mode
7
chart.interactivity("byX");
8
9
// create the first series and set the data
10
var series1 = chart.ohlc([
11
{x: Date.UTC(2007, 7, 28), open: 511.53, high: 514.98, low: 505.79, close: 506.40},
12
{x: Date.UTC(2007, 7, 29), open: 507.84, high: 513.30, low: 507.23, close: 512.88},
13
{x: Date.UTC(2007, 7, 30), open: 512.36, high: 515.40, low: 510.58, close: 511.40},
14
{x: Date.UTC(2007, 7, 31), open: 513.10, high: 516.50, low: 511.47, close: 515.25},
15
{x: Date.UTC(2007, 8, 4), open: 515.02, high: 528.00, low: 514.62, close: 525.15}
16
]);
17
18
// create the second series and set the data
19
var series2 = chart.ohlc([
20
{x: Date.UTC(2007, 7, 28), open: 525.95, high:526.10, low:520.50, close: 522.52},
21
{x: Date.UTC(2007, 7, 29), open: 522.60, high:525.69, low:521.27, close: 524.55},
22
{x: Date.UTC(2007, 7, 30), open: 522.49, high:527.91, low:522.38, close: 526.61},
23
{x: Date.UTC(2007, 7, 31), open: 524.81, high:526.83, low:520.51, close: 521.73},
24
{x: Date.UTC(2007, 8, 4), open: 529.30, high:530.50, low:528.20, close: 529.97}
25
]);
26
27
// configure the visual settings of the first series
28
series1.risingStroke("#33ccff");
29
series1.hoverRisingStroke("#33ccff", 1.5);
30
series1.selectRisingStroke("#33ccff", 3);
31
series1.fallingStroke("#ff33cc");
32
series1.hoverFallingStroke("#ff33cc", 1.5);
33
series1.selectFallingStroke("#ff33cc", 3);
34
35
// configure the visual settings of the second series
36
series2.risingStroke("#33ccff", 1, "10 5", "round");
37
series2.hoverRisingStroke("#33ccff", 1.5, "10 5", "round");
38
series2.selectRisingStroke("#33ccff", 3, "10 5", "round");
39
series2.fallingStroke("#ff33cc", 1, "10 5", "round");
40
series2.hoverFallingStroke("#ff33cc", 1.5, "10 5", "round");
41
series2.selectFallingStroke("#ff33cc", 3, "10 5", "round");
42
43
// disable markers
44
series1.hoverMarkers().enabled(false);
45
series1.selectMarkers().enabled(false);
46
series2.hoverMarkers().enabled(false);
47
series2.selectMarkers().enabled(false);
48
49
// chart title
50
chart.title("OHLC Chart: Appearance");
51
52
// set the titles of the axes
53
var xAxis = chart.xAxis();
54
xAxis.title("Date");
55
var yAxis = chart.yAxis();
56
yAxis.title("Price, $");
57
58
// set the container id
59
chart.container("container");
60
61
// initiate drawing the chart
62
chart.draw();
63
});