Clone Series from a TmpChart ?
Hi Dominik,
I've tested with it here again, now in two different computers and I can't get the error. So, please, verify that you have TeeChart 8.04 installed and check that all the search and library paths don't reference old TeeChart installations.
On the other hand, going back to the tmpChart option, I've found how you could free the tmpChart safety (it remained only a tmpChart := nil):
I've tested with it here again, now in two different computers and I can't get the error. So, please, verify that you have TeeChart 8.04 installed and check that all the search and library paths don't reference old TeeChart installations.
On the other hand, going back to the tmpChart option, I've found how you could free the tmpChart safety (it remained only a tmpChart := nil):
Code: Select all
var Stream: TMemoryStream;
tmpChart: TChart;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.AddSeries(TLineSeries.Create(self));
Chart1[0].FillSampleValues(25);
Stream := TMemoryStream.Create;
SaveChartToStream(TCustomChart(Chart1), Stream, true, false);
end;
procedure TForm1.Button1Click(Sender: TObject);
var SeriesCopy: TChartSeries;
begin
tmpChart := TChart.Create(self);
try
Stream.Position := 0;
LoadChartFromStream(TCustomChart(tmpChart), Stream);
SeriesCopy := tmpChart[0];
SeriesCopy.ParentChart := Chart2;
finally
Stream.Free;
tmpChart := nil;
tmpChart.free;
end;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Hi Dominik,
With your project's default values (Project/Options/Debug Configuration/Runtime errors/Range checking: checked) it seems to work fine.
And unchecking it, or setting Release Configuration, everything still works fine...
With your project's default values (Project/Options/Debug Configuration/Runtime errors/Range checking: checked) it seems to work fine.
And unchecking it, or setting Release Configuration, everything still works fine...
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Hi Yeray,
really strange. I got an error as soon as I enable RangeCheck.
I tried your solution with setting the TmpChart to NIL. It works, but the color changes after setting the ParentChart to TargetChart.
Is there any automatically mechanism to change the color if a new series is added? Can I switch off this behaviour during my move operation?
really strange. I got an error as soon as I enable RangeCheck.
I tried your solution with setting the TmpChart to NIL. It works, but the color changes after setting the ParentChart to TargetChart.
Is there any automatically mechanism to change the color if a new series is added? Can I switch off this behaviour during my move operation?
Hi Yeray,
today I did some new tests. I always get the error if ...
- Rangecheck is enabled
- use Project -> Create Project to compile the whole application complete (in german it´s called xxxx erzeugen - Shortcut is SHIFT + F9)
- Start the project and press the Copy Button -> Error.
My Chart has on the left side a horizontal line with 300 points added.
Find the new Upload here:
Received Object RTTI.zip Content Type application/x-zip-compressed Length 143791
Notes:
There is a small mistake of mine ... CopyEg.dpr contains a line " ExceptionLog,". Please remove this before. Sorry about that.
today I did some new tests. I always get the error if ...
- Rangecheck is enabled
- use Project -> Create Project to compile the whole application complete (in german it´s called xxxx erzeugen - Shortcut is SHIFT + F9)
- Start the project and press the Copy Button -> Error.
My Chart has on the left side a horizontal line with 300 points added.
Find the new Upload here:
Received Object RTTI.zip Content Type application/x-zip-compressed Length 143791
Notes:
There is a small mistake of mine ... CopyEg.dpr contains a line " ExceptionLog,". Please remove this before. Sorry about that.
Hi Dominik,
The problem here is that by default there is no color property saved to the series serialization because the chart palette is going to be used. Then, while the series color is the default in the palette, the stream won't save it and it won't be exported so the default in the target chart palette will be used.
I think that you should save the original color series and then force the destination series to take this color (after setting it to clNone to force the change to be applied):
The problem here is that by default there is no color property saved to the series serialization because the chart palette is going to be used. Then, while the series color is the default in the palette, the stream won't save it and it won't be exported so the default in the target chart palette will be used.
I think that you should save the original color series and then force the destination series to take this color (after setting it to clNone to force the change to be applied):
Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
var SeriesCopy: TChartSeries;
SeriesColor: TColor;
begin
tmpChart := TChart.Create(self);
try
Stream.Position := 0;
LoadChartFromStream(TCustomChart(tmpChart), Stream);
SeriesCopy := tmpChart[1];
SeriesColor := tmpChart[1].Color;
SeriesCopy.Color := clNone;
SeriesCopy.Color := SeriesColor;
SeriesCopy.ParentChart := Chart2;
finally
Stream.Free;
tmpChart := nil;
tmpChart.free;
end;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Hi Yeray,
Well this will work for some series types but not with all. If you use TFastLine you need this code:
So could you think about an generic solution which will work with all series types?
And did you try my last demo app (see posting 15 May 2009 07:38)?
Code: Select all
SeriesColor := tmpChart[1].Color;
SeriesCopy.Color := clNone;
SeriesCopy.Color := SeriesColor;
Code: Select all
SeriesColor := (tmpChart[Serie] as TFastLineSeries).LinePen.color;
(SerieCopy as TFastLineSeries).LinePen.Color := clNone;
(SerieCopy as TFastLineSeries).LinePen.Color := SeriesColor;
And did you try my last demo app (see posting 15 May 2009 07:38)?
Ups, excuse me. I think I didn't refresh the page before answering... my fault.moelski wrote:And did you try my last demo app (see posting 15 May 2009 07:38 )?
Now I've tested it (and also Narcis) and we don't see any error. Yes, really strange.
I'm afraid that there is no generic solution for this. You could test if a series is one type or another and use a casting to copy the particular series properties too:moelski wrote:So could you think about an generic solution which will work with all series types?
Code: Select all
if tmpChart[1].ClassType = TFastLineSeries then
SeriesCopy := tmpChart[1] as TFastLineSeries
else if tmpChart[1].ClassType = TLineSeries then
SeriesCopy := tmpChart[1] as TLineSeries;
SeriesColor := SeriesCopy.Color;
SeriesCopy.Color := clNone;
SeriesCopy.Color := SeriesColor;
SeriesCopy.ParentChart := Chart2;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Hi Yeray,
I found this generic solution:
This works good. I think I still have to make some enhancements, but in general this works good. What do you think about that?
I found this generic solution:
Code: Select all
SerieCopy := tmpChart[Serie];
// Farbe merken
SeriesColor := tmpChart[Serie].Color;
if IsPublishedProp(TCustomLineSeries(tmpChart[Serie]).LinePen, 'Color') then begin
SeriesLineColor := GetOrdProp(TCustomLineSeries(tmpChart[Serie]).LinePen, 'Color') ;
end;
SerieCopy.ParentChart := TargetChart;
SerieCopy.Color := clNone;
SerieCopy.Color := SeriesColor;
if IsPublishedProp(TCustomLineSeries(SerieCopy).LinePen, 'Color') then begin
TCustomLineSeries(SerieCopy).LinePen.Color := clNone;
TCustomLineSeries(SerieCopy).LinePen.Color := SeriesLineColor;
end;
Hi Dominik,
Yes, you solution seems more generic that mine. I'm pleased to see that you made it work.
Yes, you solution seems more generic that mine. I'm pleased to see that you made it work.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |