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.
Tutorials on dataset connections
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi kai,
Functions are exported and imported fine here using v7.07. Can you please test if this version works fine at your end?
Regarding the tutorials, you'll find them at TeeChart's program group and also at Docs folder created by the binary installers.
If your problem persists please send us a simple example we can run "as-is" to reproduce the problem here. You can post your examples at news://www.steema.net/steema.public.attachments newsgroup.
Thanks in advance.
Functions are exported and imported fine here using v7.07. Can you please test if this version works fine at your end?
Regarding the tutorials, you'll find them at TeeChart's program group and also at Docs folder created by the binary installers.
If your problem persists please send us a simple example we can run "as-is" to reproduce the problem here. You can post your examples at news://www.steema.net/steema.public.attachments newsgroup.
Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Functions
Hi,
saving and and loading functions works fine with 7.04.
However, my problem is that when I move series in the chart that use functions based on other series, those other series are mapped to the their relative positions (ie chart1.series[30]). So, if I insert new series in those positions, the functions use the relative series. I need some way to check what the series' mapping are to other series and increment them accordingly in the series that I'm moving..
For example, my chart contains:
series 1
series 2
series 3
series 4
series 5
...
series 28
series 29
series 30 (insert three new series here)
series 31
series 32
I need to insert 3 series between 30 and 31, save series 30 and 31 somehow and then add them back to the chart. If series 30 and 31 are functions that are dependant on each other, I need to tell them to use the series + 3 relative position.. If I don't, after inserting three new series, the old series 32 will still be using series 31 and that is the problem. But if I look at the objects, I can see that the functions are mapped to series' names. I think there is probably a solution but it may be quite complex.
The pseudo code would be:
1) Check if any series > 30 has functions
2) Obtain the series names that the functions dataset map to
3) Save the series > 30 along with their functions to a temp chart
4) Insert 3 new series into the chart
5) Append the saved series
6) Increment the functions' dataset series
7) Reconnect the datasets..
How to do that? I haven't the slightest idea how to access function's dataset series through code.. I thought perhaps there was a tutorial that would explain that but now I"m thinking that you've probably not had many requests for this type of functionality..
What I need is a tutorial on "How to insert new series into the middle of an existing chart's series and still have the moved series' functions based on dataset series still work".
Thanks.
pl
saving and and loading functions works fine with 7.04.
However, my problem is that when I move series in the chart that use functions based on other series, those other series are mapped to the their relative positions (ie chart1.series[30]). So, if I insert new series in those positions, the functions use the relative series. I need some way to check what the series' mapping are to other series and increment them accordingly in the series that I'm moving..
For example, my chart contains:
series 1
series 2
series 3
series 4
series 5
...
series 28
series 29
series 30 (insert three new series here)
series 31
series 32
I need to insert 3 series between 30 and 31, save series 30 and 31 somehow and then add them back to the chart. If series 30 and 31 are functions that are dependant on each other, I need to tell them to use the series + 3 relative position.. If I don't, after inserting three new series, the old series 32 will still be using series 31 and that is the problem. But if I look at the objects, I can see that the functions are mapped to series' names. I think there is probably a solution but it may be quite complex.
The pseudo code would be:
1) Check if any series > 30 has functions
2) Obtain the series names that the functions dataset map to
3) Save the series > 30 along with their functions to a temp chart
4) Insert 3 new series into the chart
5) Append the saved series
6) Increment the functions' dataset series
7) Reconnect the datasets..
How to do that? I haven't the slightest idea how to access function's dataset series through code.. I thought perhaps there was a tutorial that would explain that but now I"m thinking that you've probably not had many requests for this type of functionality..
What I need is a tutorial on "How to insert new series into the middle of an existing chart's series and still have the moved series' functions based on dataset series still work".
Thanks.
pl
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi kai,
Ok, instead of save series and then add them again to the chart I'd add the new series to the chart and change their order using ExchangeSeries(a, b: Integer); method. Is this a valid solution for you?
Ok, instead of save series and then add them again to the chart I'd add the new series to the chart and change their order using ExchangeSeries(a, b: Integer); method. Is this a valid solution for you?
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Success!!!
That works! Thank you very much! I really appreciate your expertise.