HTMLcopy
1
<button id="updateButton" onclick="updateRow()">Update First Row</button>
2
<label>name: <input id="nameInput" value="New Name"></label>
3
<label>value: <input id="valueInput" value="16000"></label>
4
<label>color: <input id="colorInput" value="#ef6c00"></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: 75px;
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 data
4
data = [
5
["January", 12000],
6
["February", 15000],
7
["March", 16000],
8
["April", 14000],
9
["May", 10000]
10
];
11
12
// create a data set
13
dataSet = anychart.data.set(data);
14
15
// map the data
16
var mapping = dataSet.mapAs({x: 0, value: 1, fill: 2, stroke: 2});
17
18
// create a chart
19
var chart = anychart.column();
20
21
// create a series and set the data
22
var series = chart.column(mapping);
23
24
// set the chart title
25
chart.title("Data Sets: Updating");
26
27
// set the container id
28
chart.container("container");
29
30
// initiate drawing the chart
31
chart.draw();
32
});
33
34
// update a row
35
function updateRow() {
36
var newName = document.getElementById("nameInput").value;
37
var newValue = document.getElementById("valueInput").value;
38
var newColor = document.getElementById("colorInput").value;
39
var newData = [newName, newValue, newColor];
40
dataSet.row(0, newData);
41
}