-
Notifications
You must be signed in to change notification settings - Fork 0
/
popupScriptCFA.js
46 lines (41 loc) · 1.62 KB
/
popupScriptCFA.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
// Load the Visualization API and chart packages
google.load('visualization', '1.0', {'packages':['corechart'], callback: drawPopCFAChartFromCSV});
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawPopCFAChartFromCSV);
function drawPopCFAChartFromCSV(){
// Get the csv file, and convert it into a string
$.get("csvFiles/CFOAProgramPercentages.csv", function(csvString) {
// transform the CSV string into a 2D array
var arrayData = $.csv.toArrays(csvString, {onParseValue: $.csv.hooks.castToScalar});
// convert the 2D array into a data table google charts can read
var data = new google.visualization.arrayToDataTable(arrayData);
//console.log(data);
// var data = google.visualization.arrayToDataTable([
// ['Catagory', 'Percentage'],
// ['2004', 1000],
// ['2005', 1170],
// ['2006', 660],
// ['2007', 1030]
// ]);
//
// define chart options
var options = {
title: "Cancer Fund of America",
slices: {2: {offset: 0.2}
},
colors: ['blue', 'red', 'yellow']
// hAxis: {title: data.getColumnLabel(0), minValue: data.getColumnRange(0).min, maxValue: data.getColumnRange(1).max},
// vAxis: {title: data.getColumnLabel(1), minValue: data.getColumnRange(1).min, maxValue: 100},
// legend: 'none',
// trendlines: {
// 0:{
// color: 'green'
// }
// }
};
//draw the chart
var chart = new google.visualization.PieChart(document.getElementById('popupDivCFA'));
chart.draw(data, options);
});
}
console.log("num1");