PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/kharm/public/js/google_chart.js

http://kharm-xml.googlecode.com/
JavaScript | 46 lines | 39 code | 6 blank | 1 comment | 2 complexity | af7da8e734419f51981a1177ca10f1e8 MD5 | raw file
 1/* JAVASCRIPT GOOGLE CHART */
 2
 3var chart_themes;
 4var chart_centers;
 5
 6google.load('visualization', '1', {packages:['imagepiechart']});
 7google.load('visualization', '1', {packages:['imagelinechart']});
 8
 9
10function initialize_charts() {
11	chart_themes = new google.visualization.ImagePieChart(document.getElementById('chart_themes'));
12	chart_centers = new google.visualization.ImageLineChart(document.getElementById('chart_centers'));
13}
14
15function draw_chart_themes(rows, meeting_name) {
16	var color = ["2c6dd2","d22cc0","2abc1b","f31818","d2762c"];
17	var data = new google.visualization.DataTable();
18	data.addColumn('string', 'Thčme');
19	data.addColumn('number', 'Pourcentage');
20	data.addRows(rows.length);
21	for (var i=0; i<rows.length; i++) {
22		data.setValue(i, 0, rows[i]["name"]);
23		data.setValue(i, 1, parseInt(rows[i]["percent"]));
24	}
25	chart_themes.draw(data, {colors:color, is3D: true,width: 300, height:180, backgroundColor:'#b7c2c7',
26		title: "Proportion des thčmes abordés \n dans le congrés:\n" + meeting_name});
27}
28
29function draw_chart_centers(rows) {
30	var color = ["ff0000"];
31	var data = new google.visualization.DataTable();
32	data.addColumn('string', 'Année');
33	data.addColumn('number', 'Ouvertures');
34	data.addRows(rows.length*2);
35	var i=0;
36	while (i<rows.length) {
37		data.setValue(i*2, 0, rows[i]["anneeDebut"]);
38		data.setValue(i*2, 1, parseInt(rows[i]["nombre"]));
39		data.setValue(i*2+1, 0, rows[i]["anneeFin"]);
40		data.setValue(i*2+1, 1, parseInt(rows[i]["nombre"]));
41		i++;
42	}
43	chart_centers.draw(data, 
44			{colors:color,width: 300, height: 180, min: 0, max: 8, legend:"top",
45				backgroundColor:"#f6cf7c", title:"Nombre d'ouvertures de centre"});
46}