Custom axes with automatic scaling

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
René Helbig
Newbie
Newbie
Posts: 2
Joined: Wed Jul 19, 2023 12:00 am

Custom axes with automatic scaling

Post by René Helbig » Tue Jun 10, 2025 8:16 am

Hello,

After updating to TeeChart 4.2025.2.22, my axes looses the automatic axis scaling.
The bug was introduced with Bug 2758.

In my project I use a lot of custom axes.
Some axes with automatic scaling:

Code: Select all

axis.Automatic = true
some axes with logarithmic scaling:

Code: Select all

axis.Automatic = false; 
axis.Automatic.AutomaticMaximum=true;
and some axes with a fixed scaling:

Code: Select all

axis.Minimum = 0;
axis.Maximum = 100;
Zooming with the mouse is deactivated. I create a separate rectangle for zooming.

Code: Select all

// Deactivate zooming with mouse
this.TChart.Zoom.Direction = ZoomDirections.None;
...
// Only zoom horizontal
this.TChart.Zoom.ZoomRect(new Rectangle(newStartPos, 0, newEndPos - newStartPos, 0));
After the update, my axes are no longer displayed as usual. As my rectangle for zooming has zero height, the minimum and maximum of the axes are set to 0. In addition, they are no longer scaled automatically.
Even for the axes that have a fixed minimum and maximum, the minimum and maximum change after zooming.

Marc
Site Admin
Site Admin
Posts: 1312
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: Custom axes with automatic scaling

Post by Marc » Tue Jun 10, 2025 10:48 am

Hello,

The issue is complex, both related to the earlier reported #2758 and your description here. Are you able to send us a small sample project that highlights the problem and will help us to identify a solution?

With thanks.
Regards,
Marc Meumann
Steema Support

Marc
Site Admin
Site Admin
Posts: 1312
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: Custom axes with automatic scaling

Post by Marc » Tue Jun 10, 2025 12:02 pm

...just one extra note on this, it may save needing to go to a more detailed example.

Setting a zoomrect with height zero, expresses to me a non-visible result. I may have misunderstood a part of the description and/or it may be that part of the bug #2758 was letting that kind of zoomrect for custom axes incorrectly pass through the filter, but in my view, if you wish to zoom horizontally and not vertically via a zoomrect instruction, it is more likely that it should take this kind of appearance:

Code: Select all

// Only zoom horizontal
this.TChart.Zoom.ZoomRect(new Rectangle(newStartPos, currentYMax, newEndPos - newStartPos, currentYMin));
In this case you express the x changes via newEndPos and newStartPos and leave y alone, using current values currentYMax and currentYMin.

eg.

Code: Select all

//if not axis inverted
var YTop = tChart1.Axes.Custom[0].CalcYPosValue(tChart1.Axes.Custom[0].Maximum);
var YBottom = tChart1.Axes.Custom[0].CalcYPosValue(tChart1.Axes.Custom[0].Minimum);

tChart1.Zoom.ZoomRect(new Rectangle(newStartPos, YTop, newEndPos - newStartPos, YBottom));
Regards,
Marc
Steema Support

René Helbig
Newbie
Newbie
Posts: 2
Joined: Wed Jul 19, 2023 12:00 am

Re: Custom axes with automatic scaling

Post by René Helbig » Tue Jun 10, 2025 2:03 pm

I just wanted to let you know what the code looks like for me and how it has worked so far.
I have already found out that the height of 0 has to be adjusted when zooming:

Code: Select all

var chartRect = this.TChart.Chart.ChartRect;
this.TChart.Zoom.ZoomRect(chartRect with { X = newStartPos, Width = newEndPos - newStartPos });
However, this results in the minimum and maximum of the axes being set and thus overwriting my configuration of the axes.

For example, I have a chart with three axes.
Axis 1:

Code: Select all

axis1.Minimum = 10; 
axis2.Maximum = 100;
Axis 2:

Code: Select all

axis2.Automatic = true;
Axis 3:

Code: Select all

axis3.AutomaticMaximum = true; 
axis3.Minimum = 0; 
axis3.Logarithmic = true;
After zooming the axes have the following properties:
Axis 1:

Code: Select all

axis1.Minimum == axis.CalcPosPoint(chartRect.Y); 
axis1.Maximum == axis.CalcPosPoint(chartRect.Height);
Axis 2:

Code: Select all

axis2.Automatic == false
Axis 3:

Code: Select all

axis3.AutomaticMaximum == false; 
axis3.Minium == axis.CalcPosPoint(chartRect.Y);
I think that the error is that the minimum and maximum of the axes are set when zooming and thus the automatic scaling is deactivated.

Regards,
René

Marc
Site Admin
Site Admin
Posts: 1312
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: Custom axes with automatic scaling

Post by Marc » Tue Jun 10, 2025 4:31 pm

Hello René,

Yes, I see the difference before and after build 4.2025.2.22. Turning off automatic is correct (intentional) by design; when setting SetMinMax, one is overriding automatic behaviour. That has always been the case for the main axes (Left, Top, Right, Bottom and Depth) but was missing from Custom and was corrected during the work on #2758.

Resetting all axes' to automatic after SetMinMax could, for example, be done in this way:

Code: Select all

for (int i = 0; i < tChart1.Axes.Count; i++) 
{
    tChart1.Axes[i].Automatic = true;
    tChart1.Axes[i].AdjustMaxMin();
}
tChart1.Invalidate();
I'm not saying that resolves the problem you are experiencing, you are accustomed to the zoom having worked in a certain way. We'll look now at the repercussions of the new behaviour with a view to give you a working solution.

A working sample of what you have would be useful to have, to see if your axes areas overlap or are isolated from each other, and how it behaved before. If code isn't possible, perhaps screenshots or a video. If there's an element of confidentiality then it could be sent by email to info @ steema.com. We'll work anyway, with the layouts we have, but with more information it'll be clearer to see if we're missing something.

With thanks.
Regards,
Marc
Steema Support

Marc
Site Admin
Site Admin
Posts: 1312
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: Custom axes with automatic scaling

Post by Marc » Thu Jun 12, 2025 2:45 pm

As a followup, improvements to zoom sectoring have been made for inclusion with next update.

ref. https://www.steema.com/bugs/show_bug.cgi?id=2768

Post Reply