Do ingraph labels work for HBars?

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 spinez on 21st January 2013
tried multiple ways to do it but can't seem to get it to work. can you please provide a working example of an hbar with ingraph labels?
Posted by RGraph support on 22nd January 2013
Hi,

There's an example of "ingraph" labels here (though they're called chart.labels.above - which should be true or false):

www.rgraph.net/examples/hbar.html


  

Richard, RGraph Support
Posted by spinez on 22nd January 2013
Is it not possible to have the text on the bars themselves?
Posted by RGraph support on 22nd January 2013
Hi,

Yes - you will need to add it yourself though using the coords array and the RGraph.Text() function eg:

myHBar.ondraw = function (obj)
{
     var coords = obj.coords;
     // RGraph.Text(...)
}


  

Richard, RGraph Support
Posted by spinez on 22nd January 2013
Sorry to be a bother but still can't get this to work with RGraph.Text.

If I have the following setup:

-----
var hbar = new RGraph.HBar('number', [11, 10, 6, 3, 2, 2, 1] );
hbar.Set('chart.noytickmarks', true);
hbar.Set('chart.labels', ['name1', 'name2', 'name3', 'name4', 'name5', 'name6', 'name7']);
hbar.Set('chart.labels.above', true);
hbar.Set('chart.shadow', true);
hbar.Draw();
-----

How can I get name1, name2, name3, etc inside of the bars and not on the left side of the graph? I know I can turn off the labels and/or cut off the gutter on the left but I am unable to figure out how to use RGraph.Text to get the names on the inside.

I appreciate any help!
Posted by RGraph support on 22nd January 2013
Hi,

There's an example of using the ondraw RGraph event in the demos:

www.rgraph.net/demos

And to add them to each bar you'd have to loop thru the hbar.coords array. Each element of the coords array is an array of x/y/w/h coordinates.

Don't forget to add the ondraw event before you call the .Draw() method.




  

Richard, RGraph Support
Posted by RGraph support on 22nd January 2013
Hi,

As an after thought - if you wish I can add an option and a demo for you as a "license holders customisation" to make this much easier - like the Pie chart has - as shown on this page:

www.rgraph.net/examples/pie.html


  

Richard, RGraph Support

Add a reply




« Back to message list