Can I use ASP to select data from an SQL Server to display on my charts?

« 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 Darron Michael on 19th January 2016
I'd like to use RGraph on our intranet to show some metrics from our SQL Server.

I copied one of the demo charts to a new file, and renamed it with a .asp extension.

The demo file is still viewable after changing the extension to .asp.

The asp code that fetches the values from SQL returns a string of values similar to the values from the original file. [4,7,5,3],[2,5,9,12] <- That is what I see when I view this data fetcher file in a browser.

But when I replace the original values in the demo file with the code to fetch the string of values from SQL, it generates a blank chart with just the left and bottom axis lines. No data.

I think I'm missing something simple here.

Posted by Richard on 19th January 2016

Are the values that you fetch a real JavaScript array? It doesn't sound like it. To check you can do this with you JavaScript data array (before you give it to the RGraph object):

// I don't know ASP so this is just a guess
var data = <%= data %> ;

That will print the data. The equivalent PHP (which I do know) would be this (it assumes that $data contains a string/text of data like this "[1,2,5,6,4,8]" - so it contains the square brackets as well as the numbers):

var data = <?php print($data) ?> ;


Add a reply

« Back to message list