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
]);
17
18
// map the data
19
mapping = dataTable.mapAs(
20
{open: 1, high: 2, low: 3, close: 4}
21
);
22
23
// create a stock chart
24
var chart = anychart.stock();
25
26
// create a plot
27
var plot = chart.plot(0);
28
29
// create an ohlc series
30
plot.ohlc(mapping);
31
32
// enable html for the legend title
33
plot.legend().title().useHtml(true);
34
35
// configure the format of the legend title
36
plot.legend().titleFormat(function() {
37
var date = anychart.format.dateTime(this.value, "dd MMMM yyyy");
38
return "<span style='color:#455a64;font-weight:600'>DATE: " +
39
date + "</span>";
40
});
41
42
// set the chart title
43
chart.title("AnyStock Legend: Title Text Format (Formatting Functions)");
44
45
// set the container id
46
chart.container("container");
47
48
// initiate drawing the chart
49
chart.draw();
50
});