Number of lines of text in X labels on HBar chart

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 Sadath on 21st November 2012
Hi All,

I'm using an HBar from the RGraph toolkit and need to make way for very long x labels. Each label should wrap to a maximum of 4 lines. I've tried inserting relevant breaks (\r\n) within the label, and works fine for 2 lines of text. When the label flows to the 3rd line, the first two lines always overlap. Here is my code

<script type='text/javascript'>
         window.onload = function ()
         {
               var hbar = new RGraph.HBar('myHbar', [[21],[96]]);
               hbar.Set('chart.grouping', 'grouped');
               hbar.Set('chart.colors', ['red', 'blue']);
               hbar.Set('chart.shadow', true);
               hbar.Set('chart.shadow.color', '#ccc');
               hbar.Set('chart.text.color','#000');
               hbar.Set('chart.shadow.offsetx', 0);
hbar.Set('chart.shadow.offsety', 0);
hbar.Set('chart.shadow.blur', 15);
hbar.Set('chart.gutter.left', 120);
hbar.Set('chart.events.click', myClick);
hbar.Set('chart.xmax', 100);
hbar.Set('chart.strokestyle', 'rgba(0,0,0,0)');
hbar.Set('chart.key', ['Attempt 0']);
hbar.Set('chart.key.position','gutter');
hbar.Set('chart.units.post', '%');
hbar.Set('chart.labels.above', true);
hbar.Set('chart.labels.above', true);
hbar.Set('chart.xlabels', false);
hbar.Set('chart.labels.above.decimals', 1);
hbar.Set('chart.background.grid', false);
hbar.Set('chart.noaxis',true);
hbar.Set('chart.labels', ['Long Category \r\nName for Standard \r\nCategory a little \r\nlonger ','Lead']);

hbar.Draw();
}
</script>

Can some one please tell me how I can have upto 4 lines of wraped label text on a horizantal bar graphs x labels without overlapping. Much appreciated.



Posted by RGraph support on 21st November 2012
Hi,

OK I've made an alteration in the way that multiline text is handled and you can see an example here:

dev.rgraph.net/examples/hbar.html

Try the next beta and see if it helps you.
Posted by Sadath on 21st November 2012
Superb! Thank you very much. I'm usig RGraph for a commercial project and will approch for a license very soon. Excellent support from this site, and I like RGraphs alot.

Once again thank you.

Add a reply




« Back to message list