I'm trying to use the CSV reader with the Scatter chart but not having any luck

« Back to message list

Enter your email address to get email updates on this topic. You can stop receiving updates by clicking the link in the update email messages.

Posted by Patrick on 10th March 2014
I am trying to use the csv reader to fetch data to add to a scatter chart. I get no errors but no data.
I finally tried copying your example scatter www.rgraph.net/demos/scatter-csv-reader.html with the same results.

Any hints on troubleshooting?

I would like to at least get a bare bones example working so I have a starting point.
Posted by Richard on 10th March 2014
Hi there,

1. Check to see what your CSV file looks like (through your browser).
2. console.log the csv object inside your callback function to see what it looks like.
3. Keep in mind that each Scatter point requires two numbers - the X and the Y coordinates.

Posted by Patrick on 10th March 2014

my test.csv file as displayed by Web Inspector while running my copy of your example file.
Apparently I am too stupid to properly place the console.log(csv); to get it to log.
I am a novice and I am not familiar with callback functions yet.
Posted by Richard on 10th March 2014
Hi there,

Post a URL to the page in question.

Posted by Patrick on 10th March 2014
my page is not online. I am building browser based local apps so I don't use AJAX to get the file. My csv file is already in the same directory as the html.
My problem must be with the reading of the csv file. I just got it to work by copying the data from the csv and pasting into a div like you show. There are 350 data points per variable.I would much prefer reading the file so I can give the user a choice of available files.

Do I have to run RGraph.CSV with a window.onload?

I am trying to add this to a single canvas that already has many other charts, images etc that are added and removed by the user.
This feature would add some actual user generated data to modelled data for comparison.
Posted by Enter your name... on 11th March 2014
Hi there,

That's the problem then - AJAX doesn't work with local files and the RGraph CSV reader is AJAX based- you need to be using a web-server. I think the only thing that you'd be able to do is as you said - pasting the file into the page - you could actually use the CSV reader by doing that but instead of using AJAX it can read a hidden DIV like this:

RGraph.CSV('id:myDIV', function (csv)

The id:myDIV is the ID of a hidden (or visible) DIV tag that contains the CSV data. Instead of using AJAX the CSV reader will just look for that DIV tag and use whatever it contains as the CSV data. For example:

<div id="myDIV" style="display: none">4,8,6,3,5,8,9</div>


Add a reply

« Back to message list