HTMLcopy
1
<button id="updateButton" onclick="updateRow()">Update Row</button>
2
<label>index: <input id="indexInput" type="number" min="0" max="4" value="0"></label>
3
<label>color: <input id="colorInput" value="#ef6c00"></label>
4
<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: 65px;
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
var dataSet = anychart.data.set(data);
14
15
// map the data
16
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 index = document.getElementById("indexInput").value;
37
var newColor = document.getElementById("colorInput").value;
38
mapping.set(index, "fill", newColor);
39
mapping.set(index, "stroke", newColor);
40
}