-
Notifications
You must be signed in to change notification settings - Fork 0
/
testgooglechart.html
64 lines (44 loc) · 2.08 KB
/
testgooglechart.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
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
// Load the Visualization API and the corechart package.
google.charts.load('current', {'packages':['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
google.charts.setOnLoadCallback(drawChart);
// Callback that creates and populates a data table,
// instantiates the pie chart, passes in the data and
// draws it.
function drawChart() {
// Create the data table.
var data = new google.visualization.DataTable();
data.addColumn('string', 'Weight range');
data.addColumn('number', 'Occurence');
data.addRows([['0-7', 1],['7-11', 3],['11-13', 4],['13-15', 2],['15-20', 0]]);
var data2 = new google.visualization.DataTable();
data2.addColumn('string', 'Weight Unit');
data2.addColumn('number', 'Current Weight');
data2.addColumn({ role: 'style' });
//data2.addColumn('number', 'Total Weight Limit');
data2.addRows([['KG', 10, 'grey']]);
//data2.addRows([['KG', 10, '#b87333']]);
// Set barchart options
var barchart_options = {'title':'Poids des cartons', 'width':400, 'height':300,legend:{position:"none"}};
// Instantiate and draw our barchart, passing in some options.
var barchart = new google.visualization.BarChart(document.getElementById('barchart_div'));
barchart.draw(data, barchart_options);
// Set Stacked bar chart options
var onebarchart_options = {'title':'Poids du chargement actuel', 'width':400, 'height':100, 'isStacked':true, legend:{position:"none"}};
// Instantiate and draw our stacked barchart, passing in some options.
var onebarchart = new google.visualization.BarChart(document.getElementById('onebarchart_div'));
onebarchart.draw(data2, onebarchart_options);
}
</script>
</head>
<body>
<h2>My First (Pie)Chart with Google Charts API</h2>
<p id="barchart_div">Hello World!</p>
<p id="onebarchart_div">Hello World!</p>
</body>
</html>