hbar-basic.html i need a VBscript array to be used as my axis

Share RGraph:   To help my Google visibility (it can't get much worse!), if you like and use RGraph I'd appreciate it if you could link to me

« 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 arny on 6th April 2014
I am using classic asp (vbscript) and I would like to use my vbscript array : xvals() when creating the graph object.

<script>
$(document).ready(function ()
{
    var hbar = new RGraph.HBar('cvs', [5,8,6,4,3,2,1,6,8])
                 .set('labels', ['Venus','Felicity','Cynthia','Frederick','Hoolio','Peter','Jennifer','Richard','Joathan'])
                 .draw();
         })
</script>

I need to replace [5,8,6,4,3,2,1,6,8] with my array xvals and am struggling with the syntax. Can anyone help?

Posted by Richard on 7th April 2014
I don't know any ASP but you need to make a string out of the values in yout array. I can give the relevant PHP which I suppose would be similar:

<?php
     $str = '[' . join($xvals, ',') . ']';
?>

The join() function makes a string out of the array, using a comma between the values.

And then when it comes to outputting the variable that you've made:

<script>
$(document).ready(function ()
{
     var hbar = new RGraph.HBar('cvs', <?php print($str) ?> )
                  .set('labels', ['Venus','Felicity','Cynthia','Frederick','Hoolio','Peter','Jennifer','Richard','Joathan'])
                  .draw();
          })
</script>

Richard
www.rgraph.net
If RGraph has helped you - please share the website - thanks!
Posted by Arny on 7th April 2014
Thanks you put me on the right track. The asp code is

<%="[" & Join(xvals,",") & "]"%>

instead of the php

<?php print($xvals) ?>

Will share :)
Posted by Arny on 8th April 2014
LONGER LABELS:

I would like to have longer labels, up to 50 characters. I cannot see a way to adjust the label length? Can you please help?
Posted by Richard on 8th April 2014
Hi there,

By the sounds of it you might benefit from putting \r\n at the beginning so that it uses two lines. Or perhaps use the text.angle setting.




Richard
www.rgraph.net
If RGraph has helped you - please share the website - thanks!

Add a reply




« Back to message list