Creating AxisTransformations at runtime lazarus / 55-TAChart ---------------------------------------------------------------------- fpcoder · 2013-11-21 19:53 Hi, Whats the right way to add a TAxisTransform, for example TAutoScaleAxisTransform, to a TChartAxisTransformations programmatically at runtime? I get an error when closing the app if I do it like this: //Create Transformation list aChartAxisTransformations:= TChartAxisTransformations.Create(Chart); //Create Transformation aAutoScaleAxisTransform:= TAutoScaleAxisTransform.Create(Chart); //Add Transformation to List aChartAxisTransformations.List.Add(aAutoScaleAxisTransform); ---------------------------------------------------------------------- wp · 2013-11-21 22:22 The first two statements are ok. But you should not add the AxisTransform directly to the list of the Transformations component. Just assign the Transformations property of the AxisTransform. In this way, the AxisTransform knows about the Transformations for broadcasting changes. If you only add the AxisTransform to the list as you did the Transformations are still nil which causes a crash when broadcasting: Code: [Select]//Create Transformation list aChartAxisTransformations:= TChartAxisTransformations.Create(Chart); //Create Transformation aAutoScaleAxisTransform:= TAutoScaleAxisTransform.Create(Chart); //Add Transformation to List aAutoScaleAxisTransform.Transformations := aChartAxisTransformations; ---------------------------------------------------------------------- fpcoder · 2013-11-23 17:41 That works. Thx! I'm now working on a TChartBox class that has a Panes indexed property using a TPaneList class and a TPane objects. Code: [Select]uPaneList.pas   TPane   TPaneList uChartBox.pas   TChartBox It returns a TPane object with the settings of the pane. If it works one can easily add/remove panes and series to the pane, plus adjust properties of the pane like Margin, Divider, AutoResize etc. TAChart could even be updated with this functionality and have native Panes support? Jotting down some pseudo code: Code: [Select]TPane = class   Divider: TConstantLine;   AutoResize: Boolean;   AddSeries   RemoveSeries   TPaneList = class(TObjectList)   Items[Index: Integer]: TPane read GetItem write SetItem ; default; TChartBox   Chart: TChart;   property Panes;   PaneIndex: Integer;   AddSeries;   RemoveSeries;   etc.. The TChartBox class inherits from a TFrame that contains a TChart and some more stuff. From there I'll do like this: Code: [Select]aPane:= ChartBox.AddPane; aSeries:= TLineSeries.Create; aPane.AddSeries(aSeries); or with ChartBox.Panes[ChartBox.PaneIndex] do   AddSeries(aSomeSeries) Pane.Margin Pane.Divider For the TPane class there is maybe not even the need to have a separate list of Series because all Series in a pane has the same AxisIndexY as the Axis of the Pane. One can just have a function that goes through Chart.SeriesList.AxisIndexY and get what corresponds? There should also be some visible divider between panes. Maybe TConstantLine is a candidate for that. I have caught an aggressive flu so will be out of order for a few days. But when I'm back I'll continue with this and I'm sure you will get one or two questions again. Quote from: wp on November 21, 2013, 11:22:05 pmaAutoScaleAxisTransform.Transformations := aChartAxisTransformations; [/code] ---------------------------------------------------------------------- wp · 2013-11-24 15:26 The information given above that each ChartBox contains a Chart indicates to me that you intend to group several charts into a common container. That can be done already with the standard components of Lazarus, and additionally, linking of axis ranges can be achieved by TChartExtentLink. So, I don't fully understand what you are trying to achieve. But anyway, keep us informed...