Tutorials on dataset connections
Posted: Mon Nov 27, 2006 3:01 am
Hi
I am loading teecharts from a database using streams into a chart. I recently added some series in the chart and need to move any existing customized series to be past the 3 new series that I've added to the chart.
My chart had 31 series in it, but now there are 34.
I clone any series that the user has added to a temp chart, add in my 3 new series to the existing chart and then try to add the user's series back into the chart when I load their chart from the stream. If the user has added a series which is function based on existing series, the 'connection' to the function's series is not restored. How can I make this work?
This is what I have:
var theStream: tmemoryStream;
i, thecount: integer;
tmpChart: TChart;
// Here I load the chart from a field in a database into a stream and then load the chart from the stream. That part works.. Chart1 now contains the 31 old series plus any series that the user added.
...
// This creates a temp chart and loads it with Chart1
thecount := chart1.seriesCount - 1;
tmpChart := TChart.Create(Self);
TmpChart.Assign(Chart1);
for i := 0 to Chart1.SeriesCount - 1 do
begin
CloneChartSeries(Chart1).ParentChart := TmpChart;
end;
// next, I free up the series that the user may have added
thecount := chart1.seriesCount - 1;
for i := 30 to thecount do
begin
chart1.Series[30].free;
end;
// here I add the three series programatically. (one is shown, I do this three times...
chart1.AddSeries( TLineSeries );
chart1.Series[chart1.seriesCount - 1].ParentChart := chart1;
chart1.Series[chart1.seriesCount - 1].Depth := 0;
chart1.Series[chart1.seriesCount - 1].Marks.Callout.Brush.Color := clBlack;
chart1.Series[chart1.seriesCount - 1].Marks.Style := smsValue;
chart1.Series[chart1.seriesCount - 1].Marks.Visible := False;
chart1.Series[chart1.seriesCount - 1].Color := clblue;
chart1.Series[chart1.seriesCount - 1].Pen.Width := 3;
chart1.Series[chart1.SeriesCount - 1].Title := 'Nutr Goal 1';
(Chart1.Series[chart1.SeriesCount - 1] as TLineSeries).Pointer.style := psRectangle;
(Chart1.Series[chart1.SeriesCount - 1] as TLineSeries).Pointer.VertSize := 2;
(Chart1.Series[chart1.SeriesCount - 1] as TLineSeries).Pointer.Visible := True;
chart1.Series[chart1.SeriesCount - 1].XValues.DateTime := True;
chart1.Series[chart1.SeriesCount - 1].XValues.Name := 'X';
chart1.Series[chart1.SeriesCount - 1].XValues.Order := loAscending;
chart1.Series[chart1.SeriesCount - 1].YValues.Name := 'Y';
chart1.Series[chart1.SeriesCount - 1].YValues.Order := loNone;
chart1.Series[chart1.seriesCount - 1].RefreshSeries;
// last, I try to append any series that the user may have created from the tmpchart:
for i := 30 to tmpChart.SeriesCount - 1 do
begin
chart1.addseries(CloneChartSeries(tmpChart));
end;
tmpChart.Free;
When the user's series are added back, if they were series that used functions (like subtract, sum etc) based on other series, the functions no longer work. Elsewhere in this forum, I saw that there is a "Tutorial 8 - database.." I cannot find that tutorial with TeeChart 7.04.
Is it available online? How can I check to see if a series has functions which are connected to other series and then reconnect them programatically? What is the proper method of saving a series and then adding it back to a chart?
Thanks.
I am loading teecharts from a database using streams into a chart. I recently added some series in the chart and need to move any existing customized series to be past the 3 new series that I've added to the chart.
My chart had 31 series in it, but now there are 34.
I clone any series that the user has added to a temp chart, add in my 3 new series to the existing chart and then try to add the user's series back into the chart when I load their chart from the stream. If the user has added a series which is function based on existing series, the 'connection' to the function's series is not restored. How can I make this work?
This is what I have:
var theStream: tmemoryStream;
i, thecount: integer;
tmpChart: TChart;
// Here I load the chart from a field in a database into a stream and then load the chart from the stream. That part works.. Chart1 now contains the 31 old series plus any series that the user added.
...
// This creates a temp chart and loads it with Chart1
thecount := chart1.seriesCount - 1;
tmpChart := TChart.Create(Self);
TmpChart.Assign(Chart1);
for i := 0 to Chart1.SeriesCount - 1 do
begin
CloneChartSeries(Chart1).ParentChart := TmpChart;
end;
// next, I free up the series that the user may have added
thecount := chart1.seriesCount - 1;
for i := 30 to thecount do
begin
chart1.Series[30].free;
end;
// here I add the three series programatically. (one is shown, I do this three times...
chart1.AddSeries( TLineSeries );
chart1.Series[chart1.seriesCount - 1].ParentChart := chart1;
chart1.Series[chart1.seriesCount - 1].Depth := 0;
chart1.Series[chart1.seriesCount - 1].Marks.Callout.Brush.Color := clBlack;
chart1.Series[chart1.seriesCount - 1].Marks.Style := smsValue;
chart1.Series[chart1.seriesCount - 1].Marks.Visible := False;
chart1.Series[chart1.seriesCount - 1].Color := clblue;
chart1.Series[chart1.seriesCount - 1].Pen.Width := 3;
chart1.Series[chart1.SeriesCount - 1].Title := 'Nutr Goal 1';
(Chart1.Series[chart1.SeriesCount - 1] as TLineSeries).Pointer.style := psRectangle;
(Chart1.Series[chart1.SeriesCount - 1] as TLineSeries).Pointer.VertSize := 2;
(Chart1.Series[chart1.SeriesCount - 1] as TLineSeries).Pointer.Visible := True;
chart1.Series[chart1.SeriesCount - 1].XValues.DateTime := True;
chart1.Series[chart1.SeriesCount - 1].XValues.Name := 'X';
chart1.Series[chart1.SeriesCount - 1].XValues.Order := loAscending;
chart1.Series[chart1.SeriesCount - 1].YValues.Name := 'Y';
chart1.Series[chart1.SeriesCount - 1].YValues.Order := loNone;
chart1.Series[chart1.seriesCount - 1].RefreshSeries;
// last, I try to append any series that the user may have created from the tmpchart:
for i := 30 to tmpChart.SeriesCount - 1 do
begin
chart1.addseries(CloneChartSeries(tmpChart));
end;
tmpChart.Free;
When the user's series are added back, if they were series that used functions (like subtract, sum etc) based on other series, the functions no longer work. Elsewhere in this forum, I saw that there is a "Tutorial 8 - database.." I cannot find that tutorial with TeeChart 7.04.
Is it available online? How can I check to see if a series has functions which are connected to other series and then reconnect them programatically? What is the proper method of saving a series and then adding it back to a chart?
Thanks.