Page 1 of 3
scales and axes
Posted: Sat Aug 17, 2024 12:50 am
by 17598411
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.
Re: scales and axes
Posted: Sun Aug 18, 2024 7:03 pm
by 17598411
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.
Re: scales and axes
Posted: Mon Aug 19, 2024 7:49 am
by yeray
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
Re: scales and axes
Posted: Tue Aug 20, 2024 8:16 pm
by 17598411
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.
Re: scales and axes
Posted: Tue Aug 20, 2024 8:21 pm
by yeray
Hello,
Thanks. I've updated the ticket also.
Re: scales and axes
Posted: Mon Sep 02, 2024 5:40 pm
by 17598411
I've tweaked it yet again. Updated version on my Web site at
https://www.fenichel.net/programs/ScaleTest.zip.
Re: scales and axes
Posted: Tue Sep 03, 2024 6:17 am
by yeray
Hello,
Thanks. I've updated the ticket.
Re: scales and axes
Posted: Tue Sep 03, 2024 6:29 pm
by 17598411
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.
Re: scales and axes
Posted: Sun Sep 08, 2024 6:39 pm
by 17598411
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.
Re: scales and axes
Posted: Mon Sep 09, 2024 1:47 pm
by yeray
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.
Re: scales and axes
Posted: Mon Sep 09, 2024 5:28 pm
by 17598411
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.
Re: scales and axes
Posted: Thu Sep 12, 2024 6:19 am
by yeray
Hello,
I've also added it to the public tracker (
#2740).
Re: scales and axes
Posted: Thu Sep 12, 2024 10:04 pm
by 17598411
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?
Re: scales and axes
Posted: Fri Sep 13, 2024 12:02 pm
by yeray
Hello,
We are working on a new
Distance
property.
This is how it looks for now:
- mstsc_b1hlSYOadn.gif (186.42 KiB) Viewed 51172 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.
Re: scales and axes
Posted: Fri Sep 13, 2024 6:28 pm
by 17598411
That looks good. I'll look forward to seeing it in your build for Delphi 7. Thanks for the rapid response.