Coordinated control of two Charts

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
liuxs
Newbie
Newbie
Posts: 20
Joined: Fri Dec 15, 2017 12:00 am

Coordinated control of two Charts

Post by liuxs » Mon Dec 18, 2017 11:57 pm

TChart VCL + Delphi XE7

In a Chart, I want to draw curves on two areas (Main Chart and Sub Chart), respectively, and the Sub Chart locates at the Top-Right corner of the Main Chart. I draw the curves on the Main Chart based on the top and left Axes, and the curves on the Sub Chart based on the Custom Axes.

The Scale and Increment of Custom Horizontal Axis are the same with those of the Top Axis, and The Scale and Increment of Custom Vertical Axis are the same with those of the Left Axis. After the curves on the Main Chart are drawn, I should be able to calculate the Height and Width of the Sub Chart according to the Main Chart.

The questions are as follows:
1. It is void to get and set the values of axis’s increments. So they are different on the two Charts (I hope they are the same).
2. In the Main Chart and the Sub Chart, I want to draw the Grid Lines only based on its own horizontal and vertical Axes, respectively, without the Grid Lines of another Chart.
3. Is it possible to zoom the Sub Chart and the Main Chart changes accordingly? And to zoom the Main Chart and the Sub Chart changes accordingly? Alternatively, when zooming the Sub Chart, the Main Chart keeps intact (do not change)?
4. What is the difference between axis’s LabelsFormat.Font and LabelsFont?

Thanks!
Attachments
TestProgram.rar
(7.35 KiB) Downloaded 858 times
fig.png
fig.png (28.32 KiB) Viewed 18010 times

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

Re: Coordinated control of two Charts

Post by Yeray » Wed Dec 20, 2017 9:15 am

Hello,

I've added a line of code to clear the series added at design time in your project because they were interfering with the example:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  with TheChart do
    begin
      SeriesList.Clear; // Line added
Now the example gives me this result:
Project9_2017-12-20_09-55-52.png
Project9_2017-12-20_09-55-52.png (14.66 KiB) Viewed 18002 times
liuxs wrote:1. It is void to get and set the values of axis’s increments. So they are different on the two Charts (I hope they are the same).
I can see the Increments are correct in the editor. Top and Custom 0 axes have an increment of 500, and Left and Custom 1 axes have an increment of 200.
Note the Increment property indicates is used to calculate the maximum number of labels to show without overlapping. If an overlappig is detected, the effective increment will be higher.
You can force the labels using custom labels if you want.
liuxs wrote:2. In the Main Chart and the Sub Chart, I want to draw the Grid Lines only based on its own horizontal and vertical Axes, respectively, without the Grid Lines of another Chart.
Note there's a SubChart Tool that is probably more appropriate for this usage.
In your case, what you call a Sub Chart is actually a pair of custom axes.
liuxs wrote:3. Is it possible to zoom the Sub Chart and the Main Chart changes accordingly? And to zoom the Main Chart and the Sub Chart changes accordingly? Alternatively, when zooming the Sub Chart, the Main Chart keeps intact (do not change)?
Either using Custom axes or using SubChart tool, you'll have to play with OnZoom and OnUndoZoom events to synchronize both sets of axes / charts.
liuxs wrote:4. What is the difference between axis’s LabelsFormat.Font and LabelsFont?
Both them return the same property so they are equivalent.
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

liuxs
Newbie
Newbie
Posts: 20
Joined: Fri Dec 15, 2017 12:00 am

Re: Coordinated control of two Charts

Post by liuxs » Thu Dec 21, 2017 12:42 am

liuxs wrote:
1. It is void to get and set the values of axis’s increments. So they are different on the two Charts (I hope they are the same).

I can see the Increments are correct in the editor. Top and Custom 0 axes have an increment of 500, and Left and Custom 1 axes have an increment of 200.
Note the Increment property indicates is used to calculate the maximum number of labels to show without overlapping. If an overlappig is detected, the effective increment will be higher.
You can force the labels using custom labels if you want.
How to get the Increments as shown in the editor? I need the initial values of some axes. GetHorizAxis.Increment and GetHorizAxis.CalcIncrement always return zero.

liuxs
Newbie
Newbie
Posts: 20
Joined: Fri Dec 15, 2017 12:00 am

Re: Coordinated control of two Charts

Post by liuxs » Thu Dec 21, 2017 4:31 am

liuxs wrote:
3. Is it possible to zoom the Sub Chart and the Main Chart changes accordingly? And to zoom the Main Chart and the Sub Chart changes accordingly? Alternatively, when zooming the Sub Chart, the Main Chart keeps intact (do not change)?

Either using Custom axes or using SubChart tool, you'll have to play with OnZoom and OnUndoZoom events to synchronize both sets of axes / charts.
To zoom the Sub Chart and the Main Chart, respectively, the TZoomSubChart Type is defined to record the Sub Chart Rect, Zoom Rect and whether or not clicked in the Sub Chart Rect (see MouseDown and MouseUp events). Then, I zoom the Sub Chart by SetMinMax to CustomAxes’s (see Zoom event).

When click and zoom in the Main Chart area, it works correctly. However, when click and zoom in the Sub Chart area, the Main Chart changes accordingly (I would like the Main Chart do not change at this time). In addition, the two CustomAxes is not isometric sometimes. How to solve the two problems?
Attachments
ChartZoom.zip
(9.29 KiB) Downloaded 809 times

liuxs
Newbie
Newbie
Posts: 20
Joined: Fri Dec 15, 2017 12:00 am

Re: Coordinated control of two Charts

Post by liuxs » Thu Dec 21, 2017 4:55 am

Using the same codes in another program, there are two weird results:
1.Axes Labels do not have the same size (see Fig-1), although I use the same codes to set the Chart and axes properties.
2. When click and zoom in the Sub Chart area, the Curves exceed the range of the Sub Chart area or CustomAxes range (see Fig-2).
Attachments
Fig-1.jpg
Fig-1.jpg (56.44 KiB) Viewed 17982 times
Fig-2.jpg
Fig-2.jpg (30.59 KiB) Viewed 17983 times

liuxs
Newbie
Newbie
Posts: 20
Joined: Fri Dec 15, 2017 12:00 am

Re: Coordinated control of two Charts

Post by liuxs » Sun Dec 24, 2017 8:54 am

When the Minimum and Maximum of an Axis are equal, there is only one Label on the Axis. That is correct in general. If the horizontal Axis and vertical Axis are isometric, and more than one Labels are required, is it possible to draw a number of Labels on the one-label Axis from the Axis’s Start Position to End Position?
Attachments
TestFig.jpg
TestFig.jpg (35.28 KiB) Viewed 17967 times

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

Re: Coordinated control of two Charts

Post by Marc » Thu Dec 28, 2017 10:10 am

Hello,

There's an example of Custom Labels in the main TeeChart executable demo. Follow the tree in the application to: \Axes\Labels\Custom labels

Regards,
Marc Meumann
Steema Support

liuxs
Newbie
Newbie
Posts: 20
Joined: Fri Dec 15, 2017 12:00 am

Re: Coordinated control of two Charts

Post by liuxs » Tue Jan 02, 2018 1:20 pm

When the Mouse moves on the chart, the ChartAxis Label’s Font changes to the Default Font by itself. Assigning LabelsFont.DefaultFont := false makes no difference. Why is that?

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Coordinated control of two Charts

Post by Sandra » Tue Jan 02, 2018 2:28 pm

Hello,

The problem doesn't appear for us. Could attach the code you're using because we can see where is the problem?

Thanks in advance
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply