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.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
series1.risingStroke("#0066cc");
29
series1.risingFill("#0066cc", 0.3);
30
series1.hoverRisingStroke("#0066cc", 2);
31
series1.hoverRisingFill("#0066cc", 0.1);
32
series1.selectRisingStroke("#0066cc", 4);
33
series1.selectRisingFill("#0066cc", 0.5);
34
35
series1.fallingStroke("#00cc99", 1, "10 5", "round");
36
series1.fallingFill("#00cc99", 0.3);
37
series1.hoverFallingStroke("#00cc99", 2, "10 5", "round");
38
series1.hoverFallingFill("#00cc99", 0.1);
39
series1.selectFallingStroke("#00cc99", 4, "10 5", "round");
40
series1.selectFallingFill("#00cc99", 0.5);
41
42
// configure the visual settings of the second series
43
series2.fallingHatchFill("forwardDiagonal");
44
series2.risingHatchFill("backwardDiagonal");
45
series2.hoverFallingHatchFill("diagonalCross");
46
series2.hoverRisingHatchFill("diagonalCross");
47
series2.selectFallingHatchFill("percent20");
48
series2.selectRisingHatchFill("percent20");
49
50
// set the chart title
51
chart.title("Japanese Candlestick Chart: Appearance");
52
53
// set the titles of the axes
54
var xAxis = chart.xAxis();
55
xAxis.title("Date");
56
var yAxis = chart.yAxis();
57
yAxis.title("Price, $");
58
59
// set the container id
60
chart.container("container");
61
62
// initiate drawing the chart
63
chart.draw();
64
});