Page 1 of 1

Assign TSubChartTool’s ChartRect is invalid

Posted: Fri Dec 29, 2017 5:08 am
by 16582574
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?

Re: Assign TSubChartTool’s ChartRect is invalid

Posted: Fri Dec 29, 2017 10:01 am
by Marc
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

Re: Assign TSubChartTool’s ChartRect is invalid

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

Re: Assign TSubChartTool’s ChartRect is invalid

Posted: Tue Jan 02, 2018 1:21 pm
by 10050769
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;

Re: Assign TSubChartTool’s ChartRect is invalid

Posted: Wed Jan 03, 2018 12:41 am
by 16582574
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.

Re: Assign TSubChartTool’s ChartRect is invalid

Posted: Wed Jan 03, 2018 11:46 am
by 10050769
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