Hi,
I am a new bie who is trying to chart the excel data.
I have written the code..but, I am sure there are lot of mistakes in
it..Could you please help me code?
My requirements are:
1) Reading data from the files which are in a url
First file is excel sheet data
second file consists of column labels for creating a column filter control
wrapper.
2) creating dashboard and drawing pie and bar chart based on the column
filter
I need help in reading the formatted data and creating the above control
wrappers and also creating pie and bar charts..
I have written( some of it copy pasted) a code...which is not showing
anything( obviously, it has lot of errors)
Could you please take a look at the code and correct it?
I would really appreciate your help, as this is an important task to
complete ....
please find the code in the attachment.
Thanks in advance
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/groups/opt_out.
google.load('visualization', '1', {packages: ['controls']});
google.setOnLoadCallback(drawChart);
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"
></script>
function drawChart () {
//Read the input array from a file that is stored in the url and create
control wrappers
$.ajax({
url:'C:\Users\jastik\Desktop\DataArray.kml',
type:'json',
success: function(json){
var data = google.visualization.arraytoDataTable(json);
// Define category pickers for 'Country' and 'City'
var countryPicker = new google.visualization.ControlWrapper({
'controlType': 'CategoryFilter',
'containerId': 'control1',
'options': {
'filterColumnLabel': 'Country',
'ui': {
'labelStacking': 'vertical',
'allowTyping': false,
'allowMultiple': false
}
}
});
var cityPicker = new google.visualization.ControlWrapper({
'controlType': 'CategoryFilter',
'containerId': 'control1',
'options': {
'filterColumnLabel': 'City',
'ui': {
'labelStacking': 'vertical',
'allowTyping': false,
'allowMultiple': false
}
}
});
}
});
//Read the column labels file and create a control wrapper for col labels
$.ajax({
url:'C:\Users\jastik\Desktop\StatArray.kml',
type:'json',
success: function(json){
var data = google.visualization.arraytoDaraTable(json);
var columnFilter = new google.visualization.ControlWrapper({
controlType: 'CategoryFilter',
containerId: 'colFilter_div',
options: {
filterColumnLabel: 'Statistics',
ui: {
label: 'Columns',
allowTyping: false,
allowMultiple: true,
selectedValuesLayout: 'belowStacked'
}
},
state: initState
});
var chart = new google.visualization.ChartWrapper({
chartType: 'BarChart',
containerId: 'chart_div',
dataTable: data,
options: {
title: 'Statistics',
width: 600,
height: 400
}
});
google.visualization.events.addListener(columnFilter, 'statechange',
function () {
var state = columnFilter.getState();
var row;
var columnIndices = [0];
for (var i = 0; i < state.selectedValues.length; i++) {
row = columnsTable.getFilteredRows([{column: 1, value:
state.selectedValues[i]}])[0];
columnIndices.push(columnsTable.getValue(row, 0));
}
// sort the indices into their original order
columnIndices.sort(function (a, b) {
return (a - b);
});
chart.setView({columns: columnIndices});
chart.draw();
});
columnFilter.draw();
}