Recent

Author Topic: Inversion bug in ChartEditor Demo  (Read 6196 times)

Muso

  • Sr. Member
  • ****
  • Posts: 356
Inversion bug in ChartEditor Demo
« on: July 21, 2021, 08:42:35 pm »
Take the attached version of the Chart editor demo (only difference to the original one is that it has a right axis added).

- double-click on the right axis and set the axis limits to "Inverted"
- close axis editing dialog

result: the change has no effect
The inversion works fine for the left axis. I spent a while to find out why nothing happens but cannot find the issue.

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: Inversion bug in ChartEditor Demo
« Reply #1 on: July 21, 2021, 10:40:35 pm »
Seems that Axis.Inverted operates only on the graph coordinates, i.e. the invisible coordinate system behind the chart, and thus flips the entire chart depending on the first y axis' Inverted value.

In order to invert an individual y axis you must add a TLinearAxisTransform to the transformations of the axis, and you must set the Scale parameter to -1 for inverted direction (+1 means normal direction). With multiple y axes you also need the usual TAutoScaleAxisTransform. Both transforms must exist within the same AxisTransformations component. Note that the inversion must be executed first, therefore the LinearAxisTransform must be the first one in the list. Do this for both y axes.

After this modification the code flipping the FAxis.Inverted cannot be used any more. Your new code only must set the Scale factor of the corresponding LinearAxisTransform to -1 when the checkbox in the charteditor is checked, or to +1 when it is not checked, or - simpy - LinearAxisTransform.Scale := -LinearAxisTransform.Scale with every checkbox change.

See the modified demo. The related code is in unit ceAxisFrame, methods GetLinearAxisTransform and cbInvertedChange. It is assumed that the transformations already have been set up in the object inspector - the chart editor does not create them (this is one of the reasons why a general, all-purpose chart editor is very complex, as I wrote in the other thread).

Muso

  • Sr. Member
  • ****
  • Posts: 356
Re: Inversion bug in ChartEditor Demo
« Reply #2 on: July 22, 2021, 12:40:47 am »
Seems that Axis.Inverted operates only on the graph coordinates
...
See the modified demo. The related code is in unit ceAxisFrame, methods GetLinearAxisTransform and cbInvertedChange.

Many thanks!

However, when I run your modified demo program
- then double-click on the right axis and invert it
- finally close the axis dialog with OK

It looks good.

- now I double-click on the right axis again and now the dialog tells me the axis is not inverted, see the attached screenshot.

I admit that inversion is a feature that only super specialists might need. Nevertheless I had it in my program and a colleague tested it. As expected, the first thing he did was to play with the chart properties. This way he found the issue.
Since it is quite complicated to get it right, I am reluctant if I should not just hive the inversion feature.

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: Inversion bug in ChartEditor Demo
« Reply #3 on: July 22, 2021, 11:20:14 am »
I only showed you the basic steps how to achieve inversion of individual axes in a multi-axis chart. Adaption into the rest of the charteditor demo is still open, and I would like to leave this to you as an exercise to learn how the building blocks cooperate. Simply search for FAxis.Inverted in the axis frame - this is not valid any more, you replace it by the new transformation code.

Muso

  • Sr. Member
  • ****
  • Posts: 356
Re: Inversion bug in ChartEditor Demo
« Reply #4 on: July 22, 2021, 12:23:47 pm »
Adaption into the rest of the charteditor demo is still open, and I would like to leave this to you as an exercise to learn how the building blocks cooperate.

I appreciate this. However, I am under pressure with my real-life program and therefore must focus on one thing for now. The one thing is the LiveView and I sent a patch today which will hopefully solve the last issue with this.

For the inversion, I asked my colleagues and I hide this feature now completely. The point is hereby that I am an engineer, no programmer and my programs are "just" tools for sensors we produce.

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: Inversion bug in ChartEditor Demo
« Reply #5 on: July 22, 2021, 03:03:30 pm »
Adaption into the rest of the charteditor demo is still open, and I would like to leave this to you as an exercise to learn how the building blocks cooperate.
However, I am under pressure with my real-life program and therefore must focus on one thing for now.
Do you really expect me to solve your programming issues for you? A good business model for your employer: Put so much pressure on the employees so that they search for a stupid forum member who does the coding for them and for free?

I am really glad to help others, but at some point the TAChart users must be able to solve the issues themselves. And I was trying to push you into a direction so that you can understand how the ChartEditor works.

Muso

  • Sr. Member
  • ****
  • Posts: 356
Re: Inversion bug in ChartEditor Demo
« Reply #6 on: July 22, 2021, 03:21:09 pm »
Do you really expect me to solve your programming issues for you?

No, of course not and this is why I skipped the inversion issue for now. I simply doesn't have the time to work on this and I did not request you to work on that for me.

I reported it because I thought there is an issue and maybe an easy way to fix it. Then it turned out to be too time-consuming for a feature that probably no user will ever use. Therefore I think it is fair to stop working on that and focus on other things.

For other issues I set patches and coded demo programs when I found a solution so that others can benefit from this.

 

TinyPortal © 2005-2018