Charting Bar and Pie charts using external CVS file

Share RGraph:   Share or Like RGraph on Facebook!

« 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 Roman on 1st August 2013
I did not find in your samples the case when I can use the external file as a data source. In particular, I need to query the SQL server and build the pie charts. ideally, it would be a one script but, so far, I use the SQL reporting services to generate the CVS or XML file that can be used a s a source file for data.
Any options with your software? If yes, any sample?
Posted by RGraph support on 2nd August 2013
Hi there,


To query the database you'd need to use whatever server-side scripting language that (it sounds like) you're already using (ASP? PHP?). Then you can put the data, in CSV form, in a DIV in the page. That way you can get to the data with JavaScript. There's a demo of a Bipolar here which extracts its left data and right data from a hidden DIV. I'd reccommend that you don't set the DIV as hidden until you have the chart up and running.

www.rgraph.net/demos/bipolar-csv-data.html


You could also use AJAX to request an XML - but that's far more involved - so if possible I'd advise going down the CSV route if you can.

www.rgraph.net/docs/xml-data.html




Richard, RGraph Support
Posted by Roman on 2nd August 2013
Elegant, but it is still not a pure "external file" solution. You have the data as a text with data being separated by coma and the labels assigned manually. How about this CSV file?

ThreatName,ThreatCount
BackDoor-EZC!lnk,7
Generic!atr,8
JS/Blacole-Redirect.ag,267
JS/Blacole-Redirect.u,26
JS/Exploit!JNLP,45
JS/Exploit-Blacole.aq,14
JS/Exploit-Blacole.eu,16
JS/Exploit-Blacole.gc,33
JS/Exploit-Blacole.ht,86
JS/Exploit-Blacole.ko,8
JS/IFrame.gen.j,7
JS/Redirector,9
RDN/Generic Dropper!qk,6
RDN/Generic Exploit!1m3,9
RDN/Generic PWS.y!tm,24
Sefnit-FCKH!F3A8B05B833A,72
W97M/Generic,140
ZeroAccess.eh,199
ZeroAccess.hk,205
ZeroAccess.hu,208

So,
1. You don't know the label names in advance.
2. Your code does not contain the reference to the external file as it is done in the Highcharts solution, for instance.
Posted by RGraph support on 2nd August 2013
Hi there,

How you handle the content of the CSV file is up to you. So you can parse it and then use it as labels, data, a combination of the two - whatever you wish.

You may find it easier to use JSON. With JSON you can specify labels and data quite easily.

There's basic examples of both in conjunction with AJAX here:

www.rgraph.net/docs/basic-ajax-json.html
www.rgraph.net/docs/basic-ajax-csv.html


Richard, RGraph Support
Posted by RGraph support on 2nd August 2013
Hi there,

Also - I'll add that there's a much more versatile and complete class that handles CSV files/data planned for the next release. This will make handling CSV files easier.



Richard, RGraph support
Posted by Roman on 8th August 2013
Thank you! I'll test the script with my data and look forward to the next release.

Roman
Posted by RGraph support on 8th August 2013
Hi there,

The docs page about the CSV reader will be here when its live:

www.rgraph.net/docs/csv-file-reader.html

(it's not there yet)




Richard, RGraph support

Add a reply




« Back to message list