-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbar_chart.js
55 lines (52 loc) · 1.81 KB
/
bar_chart.js
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
google.charts.load('current', {packages: ['corechart', 'bar']});
google.charts.setOnLoadCallback(drawAnnotations);
function drawAnnotations() {
var data = google.visualization.arrayToDataTable([
['City', '2010 Population', '2000 Population'],
['New York City, NY', 8175000, 8008000],
['Los Angeles, CA', 3792000, 3694000],
['Chicago, IL', 2695000, 2896000],
['Houston, TX', 2099000, 1953000],
['Philadelphia, PA', 1526000, 1517000]
]);
var data = google.visualization.arrayToDataTable([
['City', '2010 Population', {type: 'string', role: 'annotation'},
'2000 Population', {type: 'string', role: 'annotation'}],
['New York City, NY', 8175000, '8.1M', 8008000, '8M'],
['Los Angeles, CA', 3792000, '3.8M', 3694000, '3.7M'],
['Chicago, IL', 2695000, '2.7M', 2896000, '2.9M'],
['Houston, TX', 2099000, '2.1M', 1953000, '2.0M'],
['Philadelphia, PA', 1526000, '1.5M', 1517000, '1.5M']
]);
var options = {
title: 'Population of Largest U.S. Cities',
chartArea: {width: '50%'},
annotations: {
alwaysOutside: true,
textStyle: {
fontSize: 12,
auraColor: 'none',
color: '#555'
},
boxStyle: {
stroke: '#ccc',
strokeWidth: 1,
gradient: {
color1: '#f3e5f5',
color2: '#f3e5f5',
x1: '0%', y1: '0%',
x2: '100%', y2: '100%'
}
}
},
hAxis: {
title: 'Total Population',
minValue: 0,
},
vAxis: {
title: 'City'
}
};
var chart = new google.visualization.BarChart(document.getElementById('chart_div'));
chart.draw(data, options);
}