HTMLcopy
1
<button onclick="updateRow()">Update First Row</button>
2
<label>low:<input id="lowInput" value="510.69"></label>
3
<label>high:<input id="highInput" value="516.88"></label>
4
<label>color:<input id="colorInput" value="#dd2c00"></label>
5
<div id="container"></div>
CSScopy
22
1
html, body {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
7
button {
8
margin: 10px 0 0 10px;
9
}
10
label {
11
margin: 10px 0 0 10px;
12
}
13
input {
14
width: 60px;
15
margin: 10px 0 0 5px;
16
}
17
#container {
18
position: absolute;
19
width: 100%;
20
top: 35px;
21
bottom: 0;
22
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
3
// create a data table
4
dataTable = anychart.data.table(0);
5
6
// add data
7
dataTable.addData([
8
["2015-12-25", 506.69, 511.88],
9
["2015-12-26", 507.59, 514.98],
10
["2015-12-27", 505.49, 516.30],
11
["2015-12-28", 506.23, 514.72],
12
["2015-12-29", 505.38, 517.86],
13
["2015-12-30", 506.66, 516.98],
14
["2015-12-31", 505.99, 513.33],
15
["2016-01-01", 507.99, 515.29],
16
["2016-01-02", 506.18, 514.87]
17
]);
18
19
// map the data
20
mapping = dataTable.mapAs({low: 1, high: 2, fill: 3});
21
22
// create a stock chart and allow coloring individual points
23
var chart = anychart.stock(true);
24
25
// create a plot and an ohlc series
26
var ohlcSeries = chart.plot(0).rangeColumn(mapping);
27
ohlcSeries.name("ACME Corp.");
28
29
// set the chart title
30
chart.title().useHtml(true);
31
chart.title("Table Data: Updating");
32
33
// set the container id
34
chart.container("container");
35
36
// initiate drawing the chart
37
chart.draw();
38
});
39
40
// update the first row
41
function updateRow() {
42
var newLow = document.getElementById("lowInput").value;
43
var newHigh = document.getElementById("highInput").value;
44
var newColor = document.getElementById("colorInput").value
45
var newData = [["2015-12-25", newLow, newHigh, newColor]];
46
dataTable.addData(newData);
47
}