cancel
Showing results for 
Search instead for 
Did you mean: 

Graph X Labels: how to shift min/max labels to be within a graph width

ferro
Lead

 

Hi,

How to shift X labels min/max ('0' and '100') to be fully visible ?

 

 

ferro_1-1741099199605.png

 

Thanks

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
GaetanGodart
ST Employee

Hello @ferro ,

 

I don't think there is method to shift the minimal and maximal labels.

it would not make sense to shift the labels because then they would not be aligned with their value.
Instead you can just increase the margin of the graph area so that the labels are not hidden :

GaetanGodart_0-1741274468077.png
Then you can hide the y labels like so :

GaetanGodart_1-1741274512194.png

 

Regards,

 

Gaetan Godart
Software engineer at ST (TouchGFX)

View solution in original post

4 REPLIES 4
GaetanGodart
ST Employee

Hello @ferro ,

 

I don't think there is method to shift the minimal and maximal labels.

it would not make sense to shift the labels because then they would not be aligned with their value.
Instead you can just increase the margin of the graph area so that the labels are not hidden :

GaetanGodart_0-1741274468077.png
Then you can hide the y labels like so :

GaetanGodart_1-1741274512194.png

 

Regards,

 

Gaetan Godart
Software engineer at ST (TouchGFX)

Hi @GaetanGodart 

"I don't think there is method to shift the minimal and maximal labels."
Hm, unfortunate. I hoped labels could be accessed with getNextSibling () or similar.


"it would not make sense to shift the labels because then they would not be aligned"
I know, it seems a bit odd at first, but it's been like that for decades, and it seems users understand.

"Instead you can just increase the margin ..."
Thank you for this. I tried but every pixel is very presious on 320x240 display.

Thanks

Hello @ferro ,

 

We did not implement that function.

However, you can create a class that inherit from graph to be able to make your own custom graph and modify the functions there.
For your specific case, it seems that the range is exactly [0; 100] so if you modify the min and max value of the index only when drawing the labels, then it won't draw the outside labels maybes : 

GaetanGodart_0-1741344752995.png

Then you can draw them again with drawString perhaps :

GaetanGodart_1-1741344851063.png

This would work if you already know that you will have a static 0:100 graph, but then you could also simply not draw the label and add them manually on Designer.

 

You could make a custom graph where the outside labels are shifted I assume but I do not really know where to start.

 

Regards,

 

Gaetan Godart
Software engineer at ST (TouchGFX)

Thank you.