-
Notifications
You must be signed in to change notification settings - Fork 0
/
new chart.html~
68 lines (50 loc) · 1.58 KB
/
new chart.html~
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<html>
<head>
<!-- https://developers.google.com/chart/interactive/docs/animation?hl=en#Supported_Modifications -->
<!-- https://developers.google.com/chart/interactive/docs/gallery/columnchart -->
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
window.onload = function() {
var button = document.getElementById('b1');
}
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(init);
function init() {
var options = {
width: 400,
height: 240,
animation:{
duration: 1000,
easing: 'out',
},
vAxis: {minValue:0, maxValue:1000}
};
var data = new google.visualization.DataTable();
data.addColumn('string', 'N');
data.addColumn('number', 'Value');
data.addRow(['V', 200]);
var chart = new google.visualization.ColumnChart(
document.getElementById('chart_div'));
function drawChart() {
// Disabling the button while the chart is drawing.
button.disabled = true;
google.visualization.events.addListener(chart, 'ready',
function() {
button.disabled = false;
});
chart.draw(data, options);
}
button.onclick = function() {
var newValue = 1000 - data.getValue(0, 1);
data.setValue(0, 1, newValue);
drawChart();
}
drawChart();
}
</script>
</head>
<body>
<div id="chart_div" style="width: 900px; height: 500px;"></div>
<button type="button" id="b1" >Click Me!</button>
</body>
</html>