Graph.indexToScreenX() inaccurate after changing histogram bar width
Hi,
Not a question, but a bug report.
Setup:
TouchGFX 4.21.1
Simulation on VS2022
It seems that the internal variable holding the histogram bar position is not updated when the bar width is changed at execution time.
Example:
1- The bar width is set to 100 at design time.
2- During execution, we move a red vertical line at the position returned by Graph.indexToScreenX(1). The position returned by Graph.indexToScreenX(1) is 204.
// Original bar width = 100.
testPosX = Graph.indexToScreenX(1); // testPosX = 204
line1.moveTo(Graph.getX() + Graph.indexToScreenX(1), line1.getY());
line1.invalidate();
3- Bar width is changed to 50
4- We move the red vertical line at the position returned by Graph.indexToScreenX(1).
But Graph.indexToScreenX(1) still returns 204.
// New bar width = 50;
GraphHistogram1.setBarWidth(50);
testPosX = Graph.indexToScreenX(1); // testPosX = 204
line1.moveTo(Graph.getX() + Graph.indexToScreenX(1), line1.getY());
line1.invalidate();
We can of course workaround this problem by saving the design time bar width and using it to calculate the real bar coordinate:
int realX = Graph.getX() + Graph.indexToScreenX(1) + (DesignedBarWidth - GraphHistogram1.getBarWidth()) / 2;Secondly, there is a problem with Graph.indexToScreenX(x) returning a coordinate referenced to the graph, and not to the screen as you would expect.
The real screen coordinate is given Graph.getX() + Graph.indexToScreenX(x).
Maybe Graph.indexToScreenX(x) should be re-named Graph.indexToGraphX(x) and the description should be changed.
I hope it helps others.
