Assign TSubChartTool’s ChartRect is invalid

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

Assign TSubChartTool’s ChartRect is invalid

Post by liuxs » Fri Dec 29, 2017 5:08 am

Using TChart and TSubChartToolD draws LineSeries (called MainChart and SubChart). The scales and increment of horizontal and vertical axes are the same, respectively, but the sizes of the two charts are different.
I can determine the Width and Height of the SubChart’s ChartRect from the MainChart.ChartWidth and ChartHeight, but assigning SubChart.Charts[0].Chart.ChartRect.Width and Height does not work. By the way, I think that it is difficult to calculate the size of the SubChart, although assigning the TSubChart.Charts[0].Height and Width works.
How to assign the Width and Height of the SubChart’s ChartRect?

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

Re: Assign TSubChartTool’s ChartRect is invalid

Post by Marc » Fri Dec 29, 2017 10:01 am

Hello,

I've just cross-checked size. The following settings appear correct to set the SubChart Panel size:

Code: Select all

ChartTool1.Charts[0].Chart.Width := 300;
ChartTool1.Charts[0].Chart.Height := 400;
With respect to the ChartRect area, the size challenge is similar to that of the main Chart: depending on data the axis label size (length) may vary and automatically adjust the Chart Rect area. You can fix the Label Size to avoid that from happening.

eg.

Code: Select all

ChartTool1.Charts[0].Chart.LeftAxis.LabelsSize := 30;
Regards,
Marc
Steema Support

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

Re: Assign TSubChartTool’s ChartRect is invalid

Post by liuxs » Tue Jan 02, 2018 1:33 am

The SubChart and the MainChart are out of proportion in size.
How to make the horizontal and vertical axes of the two charts to be the same scales, respectively?
Attachments
fig.jpg
fig.jpg (23.83 KiB) Viewed 14140 times

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

Re: Assign TSubChartTool’s ChartRect is invalid

Post by Sandra » Tue Jan 02, 2018 1:21 pm

Hello,
I think you can use the SubChart SetMinMax method to assign the same scale as principal Chart. The code below shows you how:

Code: Select all

ChartTool1.Charts[0].Chart.Axes.Bottom.SetminMax(Chart1.Axes.Bottom.Minimum, Chart1.Axes.Bottom.Maximum);
ChartTool1.Charts[0].Chart.Axes.Left.SetminMax(Chart1.Axes.Left.Minimum, Chart1.Axes.Left.Maximum);
Also, I have realized you work with vertical axis in the principal Chart. Therefore, you must invert the axis in subChart. The line code below shows you how:

Code: Select all

ChartTool1.Charts[0].Chart.Axes.Left.Inverted:= true;
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

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

Re: Assign TSubChartTool’s ChartRect is invalid

Post by liuxs » Wed Jan 03, 2018 12:41 am

Thank you for your reply.
Taking the horizontal axes as an example. If both of the axes increments of the SubChart and MainChart are 400m, but their sizes are different in pixel (see Fig. above). I hope that the ratio of actual increment and screen increment of the two charts are the same.

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

Re: Assign TSubChartTool’s ChartRect is invalid

Post by Sandra » Wed Jan 03, 2018 11:46 am

Hello liuxs,
Taking the horizontal axes as an example. If both of the axes increments of the SubChart and MainChart are 400m, but their sizes are different in pixel (see Fig. above). I hope that the ratio of actual increment and screen increment of the two charts are the same.
The increment is calculated automatically according the space there is to draw labels, it depends always from size of chart, therefore if the size of chart is reduced the increment is recalculating because the labels don't overlap. In your case, a simple solution is try to reduce the SubChart Font Size, because you can show all labels. The line code below shows you how can do it:

Code: Select all

ChartTool1.Charts[0].Chart.Axes.Bottom.LabelsFont.Size := 5;
Hoping this helps you, otherwise don't hesitate to contact us.
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