Generally, each data point requires (x,y) coordinates for the chart, but
assuming a) you have successfully fetched the data from the file and b) you
can get by with just incrementing the 'x' values for each point, you could
try something like this:
function drawChart () {
// assumes "file" has the contents of the data file
var dataArray = file.split('\n');
var data = new google.visualization.DataTable();
data.addColumn('number', 'X');
data.addColumn('number', 'Y');
for (var i = 0; i < dataArray.length; i++) {
data.addRow([i, dataArray[i]]);
}
// create and draw chart
}
On Wednesday, March 28, 2012 9:27:17 PM UTC-4, Arif wrote:
>
> Hello,
> I am new to Google Visualization API. Here is something I need some
> help on:
> I have a text file stored in my server (I am using XAMPP, i.e. apache
> as the server). The text file is simple - just one integer per line,
> like this:
> 2000
> 1794
> 1585
> 1393
> 1195
> 1044
> 891
> 771
> 662
> 570
>
> I need to "read" the file (which is in a specified directory), then
> display a line chart from the data read.
> I was trying to feed an array of data to
> google.visualization.DataTable() but failed.
>
> Any working example would be greatly appreciated.
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-visualization-api/-/CrIbjp_qlMIJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-visualization-api?hl=en.