Page 1 of 1

Coordinated control of two Charts

Posted: Mon Dec 18, 2017 11:57 pm
by 16582574
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!

Re: Coordinated control of two Charts

Posted: Wed Dec 20, 2017 9:15 am
by yeray
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 21439 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.

Re: Coordinated control of two Charts

Posted: Thu Dec 21, 2017 12:42 am
by 16582574
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.

Re: Coordinated control of two Charts

Posted: Thu Dec 21, 2017 4:31 am
by 16582574
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?

Re: Coordinated control of two Charts

Posted: Thu Dec 21, 2017 4:55 am
by 16582574
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).

Re: Coordinated control of two Charts

Posted: Sun Dec 24, 2017 8:54 am
by 16582574
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?

Re: Coordinated control of two Charts

Posted: Thu Dec 28, 2017 10:10 am
by Marc
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

Re: Coordinated control of two Charts

Posted: Tue Jan 02, 2018 1:20 pm
by 16582574
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?

Re: Coordinated control of two Charts

Posted: Tue Jan 02, 2018 2:28 pm
by 10050769
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