I don't know of any examples of using XML to load data for the
Visualization API. Basically, you would need to write an AJAX function to
get the data, parse it into an XMLDocument object, and then parse the
document object to pull out the data and input it into a DataTable. jQuery
has a lot of built-in functionality to handle this kind of stuff; I expect
other libraries do as well. Here's a basic example that I think should
work:
$.ajax({
url: 'myXML.xml',
dataType: 'xml',
success: function (xml) {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Name');
data.addColumn('number', 'Value');
$('row', xml).each(function () {
var name = $('name', this).text();
var value = parseInt($('value', this).text());
data.addRow([name, value]);
});
var chart = new
google.visualization.LineChart(document.querySelector('#chart_div'));
chart.draw(data, {
height: 400,
width: 600
});
}
});
given an XML structure like this:
<rows>
<row>
<name>foo</name>
<value>5</value>
</row>
<row>
<name>bar</name>
<value>7</value>
</row>
<row>
<name>cad</name>
<value>4</value>
</row>
</rows>
On Friday, May 16, 2014 1:59:06 AM UTC-4, David Kasabji wrote:
>
> Hello,
>
> I am sorting a huge databse into an XML file, and I need to take some data
> from that database as INPUT for tha Google Charts (for example for Column
> Chart).
> I have been struggling to find any good tutorials on how to do this,
> ussually people just link some general stuff, but not specificly for Google
> Charts.
>
> So any input, maybe even walkthrough, would be really really appreciated.
>
> Thanks in advance!
>
> BR,
> David
>
--
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/d/optout.