Re: SubChart’s Series disappear
Posted: Thu Aug 13, 2020 11:06 am
Hello!
The Margins require no code change, as they automatically change the ChartRect size - the Offsets do require a change, as they affect the values of pixelXUnit and pixelYUnit. In the following code, press Button1 to make changes and then the modified Button2 to see the results:
Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
begin
//VCLTee.EditChar.EditChart(Self, Chart1);
Chart1.MarginUnits:=muPixels;
Chart1.MarginBottom:=40;
Chart1.MarginTop:=40;
Chart1.MarginLeft:=40;
Chart1.MarginRight:=40;
Chart1.Axes.Left.MinimumOffset:=20;
Chart1.Axes.Left.MaximumOffset:=20;
Chart1.Axes.Bottom.MinimumOffset:=20;
Chart1.Axes.Bottom.MaximumOffset:=20;
end;
procedure TForm1.Button2Click(Sender: TObject);
var charRect, subRect : TRect;
pixelXUnit,pixelYUnit:Double;
subBottomMax,subLeftMax:Double;
begin
charRect:=Chart1.ChartRect;
subRect:=SubChart.ChartRect;
pixelXUnit:=(Chart1.Axes.Bottom.Maximum-Chart1.Axes.Bottom.Minimum)/(charRect.Width-Chart1.Axes.Bottom.MinimumOffset-Chart1.Axes.Bottom.MaximumOffset);
pixelYUnit:=(Chart1.Axes.Left.Maximum-Chart1.Axes.Left.Minimum)/(charRect.Height-Chart1.Axes.Left.MinimumOffset-Chart1.Axes.Left.MaximumOffset);
subBottomMax:=pixelXUnit*subRect.Width;
subLeftMax:=pixelYUnit*subRect.Height;
SubChart.Axes.Bottom.SetMinMax(Chart1.Axes.Bottom.Minimum, subBottomMax);
SubChart.Axes.Left.SetMinMax(Chart1.Axes.Left.Minimum, subLeftMax);
end;