scales and axes

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Fenichel
Newbie
Newbie
Posts: 28
Joined: Fri Jul 19, 2024 12:00 am

scales and axes

Post by Fenichel » Sat Aug 17, 2024 12:50 am

The conceptualization of TeeChart might be enhanced if the notions of axis and scale were separated. When a series (say, temperatures on dates) is plotted, there must be vertical & horizontal axes with minima and maxima, to determine what temperatures are too low or too high, and what dates are too early or too late, to plot. After those limits are imposed, however, the user should be able to see multiple scales (say, Fahrenheit & Celsius, or calendar date & day of year) to help interpret the data.

I have implemented a fairly general workaround (see the attachment), but it would be less of a kludge if the axis/scale distinction were directly supported by TeeChart.
Attachments
ScaleTest.zip
demo
(509.99 KiB) Downloaded 2182 times

Fenichel
Newbie
Newbie
Posts: 28
Joined: Fri Jul 19, 2024 12:00 am

Re: scales and axes

Post by Fenichel » Sun Aug 18, 2024 7:03 pm

I have simplified the implementation of this workaround.

As TeeChart now works, every tChartAxis seems to need to have at least one associated series, even if that series contains no data. My earlier implementation required that empty series be added to the target tCustomChart at design time. It turns out that the necessary pro-forma series can be created at run time when the new scales are created.

A demo package is on my Web site at https://www.fenichel.net/programs/ScaleTest.zip.

Yeray
Site Admin
Site Admin
Posts: 9622
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: scales and axes

Post by Yeray » Mon Aug 19, 2024 7:49 am

Hello,

Thanks for the ideas and the code example.
Your tScale class looks interesting.
I've created an issue at bugzilla to discuss about it with the team: #2737
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Fenichel
Newbie
Newbie
Posts: 28
Joined: Fri Jul 19, 2024 12:00 am

Re: scales and axes

Post by Fenichel » Tue Aug 20, 2024 8:16 pm

I have further tweaked my implementation. Now it allows the outlying scales to be arbitrarily computed from the parent axes. The updated demo has replaced the older one on my Web site.

Yeray
Site Admin
Site Admin
Posts: 9622
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: scales and axes

Post by Yeray » Tue Aug 20, 2024 8:21 pm

Hello,

Thanks. I've updated the ticket also.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Fenichel
Newbie
Newbie
Posts: 28
Joined: Fri Jul 19, 2024 12:00 am

Re: scales and axes

Post by Fenichel » Mon Sep 02, 2024 5:40 pm

I've tweaked it yet again. Updated version on my Web site at https://www.fenichel.net/programs/ScaleTest.zip.

Yeray
Site Admin
Site Admin
Posts: 9622
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: scales and axes

Post by Yeray » Tue Sep 03, 2024 6:17 am

Hello,

Thanks. I've updated the ticket.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Fenichel
Newbie
Newbie
Posts: 28
Joined: Fri Jul 19, 2024 12:00 am

Re: scales and axes

Post by Fenichel » Tue Sep 03, 2024 6:29 pm

An old issue that should be somehow linked to the scales & axes discussion is control of the spacing between an axis (or scale) and its title. The spacing automatically applied seems to take account of the axis's label size, but often that spacing is unnecessarily large. As seen in my scale/axis demo, this is a greater problem when a scale is parallel to an axis, and the (inner) axis label is positioned so far out that it wrongly looks as if it belongs to the (outer) scale.
It might be possible to improve the automatic spacing, but instead (or also) you might add a new, user-controllable Title.Position2 parameter, working at right angles to the axis while the existing Title.Position parameter would continue to work parallel to the axis.

Fenichel
Newbie
Newbie
Posts: 28
Joined: Fri Jul 19, 2024 12:00 am

Re: scales and axes

Post by Fenichel » Sun Sep 08, 2024 6:39 pm

How does TChart determine the left-to-right order of a vertical axis and its title? Is there a way to control this?
  • The title is always to the left of the left axis. Good.
  • The title is always to the right of the right axis. Good again, but
  • The title seems to be fixedly to the left of a created axis, even when this axis is created as an auxiliary right scale.

Yeray
Site Admin
Site Admin
Posts: 9622
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: scales and axes

Post by Yeray » Mon Sep 09, 2024 1:47 pm

Hello,

Let me simplify it talking about the vertical axis; the according variations would apply to the horizontal axis.
The x position to draw the left axis title is calculated considering the width of the left axis labels. Why we don't provide mechanisms to modify this x position as we consider this is the behaviour the majority of users would expect. Could you please confirm this the you are willing to modify?
If so, for now I'd suggest you to draw your title manually at the OnAfterDraw event.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Fenichel
Newbie
Newbie
Posts: 28
Joined: Fri Jul 19, 2024 12:00 am

Re: scales and axes

Post by Fenichel » Mon Sep 09, 2024 5:28 pm

The x position to draw the left axis title is calculated considering the width of the left axis labels. Why we don't provide mechanisms to modify this x position as we consider this is the behaviour the majority of users would expect. Could you please confirm this the you are willing to modify?
Yes, that's what I want to modify.
  • As seen in my scale demo, the default title position of the left axis is sometimes far to the left of the axis. This position makes it difficult to place a scale slightly further left, without adding a lot of blank space to the margin.
  • As I noted in my message, the title position of a created vertical axis seems always to be the left of the axis. This looks silly when the new axis is to be placed as an alternative scale for the right axis.
If so, for now I'd suggest you to draw your title manually at the OnAfterDraw event
Well, yes, but OnAfterDraw here is an admission of inadequate parameterization. An alternative might be to create two axes for each scale, one visible with no title, and one invisible with a visible title. It's hard to say which of these solutions is uglier.

Yeray
Site Admin
Site Admin
Posts: 9622
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: scales and axes

Post by Yeray » Thu Sep 12, 2024 6:19 am

Hello,

I've also added it to the public tracker (#2740).
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Fenichel
Newbie
Newbie
Posts: 28
Joined: Fri Jul 19, 2024 12:00 am

Re: scales and axes

Post by Fenichel » Thu Sep 12, 2024 10:04 pm

I've looked into the approach of controlling an axis's title position (normal to the axis) by using a separate title axis for each axis (including each added axis-as-scale). It works well as a means of providing left and bottom scales, but it started becoming a hairball when I tried to extend it to the right side. Because the right axis sits at X=100, I expected its default PositionPercent to be 100, with increases moving it further right, analogous to the axes that sit at X=0 and Y=0 and have default PositionPercents of 0, with increases in PositionPercent resulting in increases in those coordinates.

Coping with the special properties of the right axis (Default PositionPercent of 0, with increases decreasing X) would require looking out for it whenever, for example, one wanted (see my ToggleGrid method) to swap the positions of the right-axis scale and an auxiliary right-sided scale. Feasible, but unattractive.

Do you have any idea where your #2740 stands in your queue?

Yeray
Site Admin
Site Admin
Posts: 9622
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: scales and axes

Post by Yeray » Fri Sep 13, 2024 12:02 pm

Hello,

We are working on a new Distance property.
This is how it looks for now:
mstsc_b1hlSYOadn.gif
mstsc_b1hlSYOadn.gif (186.42 KiB) Viewed 51058 times
Note in that trackbar I'm setting all 4 axes at once, but that's property is per-axis.

I'm afraid that property won't get into the build we are preparing to support the new RAD 12.2.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Fenichel
Newbie
Newbie
Posts: 28
Joined: Fri Jul 19, 2024 12:00 am

Re: scales and axes

Post by Fenichel » Fri Sep 13, 2024 6:28 pm

That looks good. I'll look forward to seeing it in your build for Delphi 7. Thanks for the rapid response.

Post Reply