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.candlestick();
5
6
// set the interactivity mode
7
chart.interactivity("by-x");
8
9
// create the first series and set the data
10
var series1 = chart.candlestick([
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.candlestick([
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
29
series1.normal().fallingFill("#00cc99", 0.3);
30
series1.normal().fallingStroke("#00cc99", 1, "10 5", "round");
31
series1.hovered().fallingFill("#00cc99", 0.1);
32
series1.hovered().fallingStroke("#00cc99", 2, "10 5", "round");
33
series1.selected().fallingFill("#00cc99", 0.5);
34
series1.selected().fallingStroke("#00cc99", 4, "10 5", "round");
35
36
series1.normal().risingFill("#0066cc", 0.3);
37
series1.normal().risingStroke("#0066cc");
38
series1.hovered().risingFill("#0066cc", 0.1);
39
series1.hovered().risingStroke("#0066cc", 2);
40
series1.selected().risingFill("#0066cc", 0.5);
41
series1.selected().risingStroke("#0066cc", 4);
42
43
// configure the visual settings of the second series
44
45
series2.normal().fallingFill("#00cc99", 0.3);
46
series2.normal().fallingHatchFill("forward-diagonal", "#00cc99");
47
series2.normal().fallingStroke("#00cc99", 1, "10 5", "round");
48
series2.hovered().fallingFill("#00cc99", 0.1);
49
series2.hovered().fallingHatchFill("forward-diagonal", "#00cc99");
50
series2.hovered().fallingStroke("#00cc99", 2, "10 5", "round");
51
series2.selected().fallingFill("#00cc99", 0.5);
52
series2.selected().fallingStroke("#00cc99", 4, "10 5", "round");
53
series2.selected().fallingHatchFill("forward-diagonal", "#00cc99");
54
55
series2.normal().risingFill("#0066cc", 0.3);
56
series2.normal().risingHatchFill("forward-diagonal", "#0066cc");
57
series2.normal().risingStroke("#0066cc");
58
series2.hovered().risingFill("#0066cc", 0.1);
59
series2.hovered().risingHatchFill("forward-diagonal", "#0066cc");
60
series2.hovered().risingStroke("#0066cc", 2);
61
series2.selected().risingFill("#0066cc", 0.5);
62
series2.selected().risingStroke("#0066cc", 4);
63
series2.selected().risingHatchFill("forward-diagonal", "#0066cc");
64
65
// set the chart title
66
chart.title("Japanese Candlestick Chart: Appearance");
67
68
// set the titles of the axes
69
var xAxis = chart.xAxis();
70
xAxis.title("Date");
71
var yAxis = chart.yAxis();
72
yAxis.title("Price, $");
73
74
// set the container id
75
chart.container("container");
76
77
// initiate drawing the chart
78
chart.draw();
79
});