Skip to main content
franck23
Associate III
March 27, 2023
Solved

Histogram X scale cannot be set to display only 1 bar

  • March 27, 2023
  • 5 replies
  • 1795 views

Hi,

Scaling down an histogram graph to display only one bar triggers a "(min != max)" error.

I need to display from 1 to 16 bars on my histogram.

I use the setGraphRangeX(int min, int max) function for this.

However, when I get down to 1 bar with setGraphRangeX(0, 0) I get an error during execution.

This error is clear enough, but I think this limitation should not be there.

Is there anyway to get around it?

Thanks,

Franck.

Setup:

TouchGFX 4.21.1

Error reproduced using TouchGFX simulator and VS2022

This topic has been closed for replies.
Best answer by Yoann KLEIN

Hello,

I think there is also a setGraphRangeX() method with float xmin and xmax parameters.

What if you try to use setGraphRangeX(0, 0.5) or something similar ?

I understand your problem and will discuss it with my colleagues, but that could be a work-around in the meantime.

/Yoann

5 replies

Yoann KLEIN
ST Employee
March 28, 2023

Hello @Community member​,

setGraphRangeX(0, 0) does mean that you wanna display data between xmin = 0 and xmax = 0 :

0693W00000aJqgQQAS.png 

So it means that you are basically showing nothing. If you wanna display only the first bar, I guess it should be setGraphRangeX(0, 1) instead.

For me, this limitation makes good sense, could you maybe elaborate why it doesn't look right for you and explain what we should implement instead ?

Thanks,

/Yoann

Yoann KLEINST Software Developer | TouchGFX
franck23
franck23Author
Associate III
March 28, 2023

Hi Yoann,

Thanks for the answer.

Yes, I would like to display xmin = 0 and xmax = 0 to get only one bar.

This would show only the first data point (data at position 0).

setGraphRangeX(0, 2) => displays 3 bars

setGraphRangeX(0, 1) => displays 2 bars

setGraphRangeX(0, 0) => triggers an error, so we cannot display only 1 data point.

The limitation should be xmin > xmax instead of xmin != xmax

Franck.

Yoann KLEIN
Yoann KLEINBest answer
ST Employee
March 28, 2023

Hello,

I think there is also a setGraphRangeX() method with float xmin and xmax parameters.

What if you try to use setGraphRangeX(0, 0.5) or something similar ?

I understand your problem and will discuss it with my colleagues, but that could be a work-around in the meantime.

/Yoann

Yoann KLEINST Software Developer | TouchGFX
franck23
franck23Author
Associate III
March 28, 2023

Yes, nice trick!

It does work using float parameters.

I used setGraphRangeX(0.0f, 0.0001f + Range) instead of 0.5f + Range as the 0.5f adds some margin on the right when the range is set to the maximum.

BTW, I think I found another where the bar position is not valid anymore after changing the bar width.

I am trying to wrap my head around it and will be posting a new thread.

Thanks for your help.

Yoann KLEIN
ST Employee
March 30, 2023

Hi,

No need to create a new post, you can just answer here and tag me to be sure I see it :)

/Yoann

Yoann KLEINST Software Developer | TouchGFX