[Lazarus] How to create a chart in code?
Felipe Monteiro de Carvalho
felipemonteiro.carvalho at gmail.com
Sat Jul 2 15:11:13 CEST 2011
Hello,
I am trying to use TAChart, so I dropped TChart in my form and I added
some code to draw some lines:
var
LineSeries: TLineSeries;
i, j: Integer;
begin
for i := 0 to Length(Model.PoliticalParties) - 1 do
begin
LineSeries := TLineSeries.Create(Application);
for j := 0 to Length(Model.PoliticalParties[i].ElectionPools)-1 do
LineSeries.AddXY(j, Model.PoliticalParties[i].ElectionPools[j]);
chartPools.Series.List.Add(LineSeries);
end;
end;
But then it crashes here:
procedure TCustomChartSeries.GetGraphBounds(var ABounds: TDoubleRect);
begin
GetBounds(ABounds);
with ABounds do begin
TransformByAxis(FChart.AxisList, AxisIndexX).UpdateBounds(a.X,
b.X); <---- crash
TransformByAxis(FChart.AxisList, AxisIndexY).UpdateBounds(a.Y, b.Y);
if IsRotated then begin
Exchange(a.X, a.Y);
Exchange(b.X, b.Y);
end;
end;
end;
Any ideas how I should add some lines to the chart instead?
The wiki is down, by the way.
thanks,
--
Felipe Monteiro de Carvalho
More information about the Lazarus
mailing list