View labels even if there is not enough space for them

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 Chuan Guo on 25th January 2016
Hi,

About the Label of XAxis, I have a chart in a small area, all the labels are shown, therefore they are overlapped, is it possible in RGraph, not to show all labels, if there is not enough place?

Thank you very much for the help!
Chuan
Posted by Richard on 25th January 2016
Hi,

You have a few options:

1. You can use the textAngle option to rotate the labels. You'll probably need to increase the bottom gutter to accommodate the increased height.

2. You can spread the labels over multiple lines by appending \r\n to every second labe;. This will give you two rows of labels. Again you'll need to increase the size of the bottom gutter.

3. You could omit every other label. Probably not the most ideal of options.






Richard
Posted by Chuan Guo on 25th January 2016
Hi Richard,

I've used the 1 & 3, just curious, if there is easy way to automate this, because for different situation developer must compute self, it's not convenient, especially when man don't know how many data there are in advance... nevertheless, thank you very much for the tips.

By the way, just noticed another small thing:
if I move mouse over the bars, besides Tooltips the whole chart is somehow blinked/jittered, could we deactivate this "effect"?

Best regards,
Chuan
Posted by Richard on 25th January 2016
Hi,

There's no way to automate it I'm afraid - so just choose an angle that looks reasonable in both circumstances.

I suppose you could use the RGraph.measureText() function to measure each label and only set the angle in relevant cases.

I don't know what the blink is, you'll need to post a link to an example. Maybe your browser is zoomed in? That can occasionally cause it. Try pressing CTRL+0







Richard
Posted by Chuan Guo on 25th January 2016
thank you very much! it's unexpected zoom in :)

The "automatic" I mean is the solution 3, we can check the width & the length of labels, if the width is shorter than the length of all labels, then only show one of every N (2, 3...) labels, many ChartLib provide this as default behavior.

Regards,
Chuan
Posted by Richard on 25th January 2016
Hi,

There's no auto measuring for labels - though I supposed you could do this with the RGraph.measureText() function. Perhaps add all of the widths of the labels together and see if it's greater than the horizontal width:

var hwidth = obj.canvas.width - 25 - 25;

25 is the default left/right gutters.






Richard

Add a reply




« Back to message list