Clone TChart to TQRChart
Clone TChart to TQRChart
Hello!
I'm trying to copy my TChart to a TQRChart for printout. Most things seem to work but all my custom axis seems to dissapear!?
AQRChart.Chart.Assign(AChart);
for t:=0 to AChart.SeriesCount-1 do
CloneChartSeries(AChart[t]).ParentChart:=AQRChart.Chart;
I cant find any CloneChartAxis! How do I clone the axis and assign all my cloned series to them?
Best regards, Mikael
I'm trying to copy my TChart to a TQRChart for printout. Most things seem to work but all my custom axis seems to dissapear!?
AQRChart.Chart.Assign(AChart);
for t:=0 to AChart.SeriesCount-1 do
CloneChartSeries(AChart[t]).ParentChart:=AQRChart.Chart;
I cant find any CloneChartAxis! How do I clone the axis and assign all my cloned series to them?
Best regards, Mikael
Re: Clone TChart to TQRChart
Hi Mikael,
For printing, it may be easier to use a bitmap. You could have a TQRImage in your TQuickRep and then assign the chart bitmap exported with TeeBitmap function.
This works fine for me here:
I see the Assign function copies the series and the custom axes from the origin chart to the destination chart. What it isn't copying are the relations between the series and the custom axes. I've added it to the wish list to be revised forfuture releases (TV52016721).
In the meanwhile, if you know the relations, you could manually assing them after the code you posted above, or after calling the CloneChart function:
Or:
For printing, it may be easier to use a bitmap. You could have a TQRImage in your TQuickRep and then assign the chart bitmap exported with TeeBitmap function.
This works fine for me here:
Code: Select all
procedure TForm1.AssignToImage(AQRImage: TQRImage; AChart: TChart);
var tmpBitmap: TBitmap;
begin
tmpBitmap:=AChart.TeeCreateBitmap;
AQRImage.Picture.Bitmap:=tmpBitmap;
AQRImage.Width:=tmpBitmap.Width;
AQRImage.Height:=tmpBitmap.Height;
end;
In the meanwhile, if you know the relations, you could manually assing them after the code you posted above, or after calling the CloneChart function:
Code: Select all
AQRChart.Chart.Assign(AChart);
for t:=0 to AChart.SeriesCount-1 do
CloneChartSeries(AChart[t]).ParentChart:=AQRChart.Chart;
for t:=0 to AQRChart.Chart.SeriesCount-1 do
AQRChart.Chart[t].CustomVertAxis:=AQRChart.Chart.CustomAxes[t];
Code: Select all
CloneChart(AQRChart.Chart, AChart, Self, false);
for t:=0 to AQRChart.Chart.SeriesCount-1 do
AQRChart.Chart[t].CustomVertAxis:=AQRChart.Chart.CustomAxes[t];
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Clone TChart to TQRChart
Hello!
Ok, thanks!
I cant use the BitMap solution as there are several changes done on the printout in respect to the original.
The problem is that i have about 40 series spread over about 30 different scales so your "one to one" copy does not work.
Any easy code to find out which custom axis i should apply each copied serie to?
Regards, Mikael
Ok, thanks!
I cant use the BitMap solution as there are several changes done on the printout in respect to the original.
The problem is that i have about 40 series spread over about 30 different scales so your "one to one" copy does not work.
Any easy code to find out which custom axis i should apply each copied serie to?
Regards, Mikael
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Clone TChart to TQRChart
Hi Mikael,
The examples with CustomVertAxis and CustomAxes Yeray posted in his last reply don't help with this?Any easy code to find out which custom axis i should apply each copied serie to?
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 |
Re: Clone TChart to TQRChart
Hello!
No it does not work, if you check his code:
CloneChart(AQRChart.Chart, AChart, Self, false);
for t:=0 to AQRChart.Chart.SeriesCount-1 do
AQRChart.Chart[t].CustomVertAxis:=AQRChart.Chart.CustomAxes[t];
He assumes a 1:1 relationship between the Series and the CustomAxes but some of my Seried share the same axes!
Best regards, Mikael
No it does not work, if you check his code:
CloneChart(AQRChart.Chart, AChart, Self, false);
for t:=0 to AQRChart.Chart.SeriesCount-1 do
AQRChart.Chart[t].CustomVertAxis:=AQRChart.Chart.CustomAxes[t];
He assumes a 1:1 relationship between the Series and the CustomAxes but some of my Seried share the same axes!
Best regards, Mikael
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Clone TChart to TQRChart
Hi Mikael,
I see, it probably should be something like this:
Where series axes settings are copied from one chart to the other.
I see, it probably should be something like this:
Code: Select all
for t:=0 to AQRChart.Chart.SeriesCount-1 do
AQRChart.Chart[t].CustomVertAxis:=AChart.Chart[t].CustomVertAxis;
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 |
Re: Clone TChart to TQRChart
Ok, thanks. I'll test it!
Re: Clone TChart to TQRChart
Sorry, but I can't make it work!
I'm using TeeChart 8.07, is this maybee the problem. Is this functionality improved in later version?
My latest try is below. The problem is I can't get my custom axes to be copied currectly. On my original Chart I can see 20 series but on my report there are only two. Probably they are to high or low to be visible as their axes are not copied/assigned correctly.
Best regards, MIkael
// Copy chart
QRDataChart.Chart.FreeAllSeries;
QRDataChart.Chart.Assign(DataChart);
// Copy series
For I := 0 To DataChart.SeriesCount - 1 Do
Begin
CloneChartSeries(DataChart).ParentChart := QRDataChart.Chart;
QRDataChart.Chart.Series.CustomVertAxis := DataChart.Series.CustomVertAxis;
End;
I'm using TeeChart 8.07, is this maybee the problem. Is this functionality improved in later version?
My latest try is below. The problem is I can't get my custom axes to be copied currectly. On my original Chart I can see 20 series but on my report there are only two. Probably they are to high or low to be visible as their axes are not copied/assigned correctly.
Best regards, MIkael
// Copy chart
QRDataChart.Chart.FreeAllSeries;
QRDataChart.Chart.Assign(DataChart);
// Copy series
For I := 0 To DataChart.SeriesCount - 1 Do
Begin
CloneChartSeries(DataChart).ParentChart := QRDataChart.Chart;
QRDataChart.Chart.Series.CustomVertAxis := DataChart.Series.CustomVertAxis;
End;
Re: Clone TChart to TQRChart
Hi Mikael,
Give it a try to the following. I'm searching for the relations and assigning them accordingly. I'm only doing it only for the CustomVerticalAxis, but you shouldn't find problems to expand it for the CustomHorizontalAxis too if you also need it:
Give it a try to the following. I'm searching for the relations and assigning them accordingly. I'm only doing it only for the CustomVerticalAxis, but you shouldn't find problems to expand it for the CustomHorizontalAxis too if you also need it:
Code: Select all
uses Series;
procedure TForm1.FormCreate(Sender: TObject);
var i, nSeries: Integer;
begin
nSeries:=4;
Chart1.View3D:=false;
for i:=0 to nSeries-1 do
begin
Chart1.AddSeries(TLineSeries).FillSampleValues;
if i>0 then
begin
Chart1[i].CustomVertAxis:=Chart1.CustomAxes.Add;
with Chart1[i].CustomVertAxis do
begin
StartPosition:=i*(100/nSeries);
EndPosition:=(i+1)*(100/nSeries);
Axis.Color:=Chart1[i].Color;
LabelsFont.Color:=Chart1[i].Color;
end;
end;
end;
with Chart1.Axes.Left do
begin
EndPosition:=100/nSeries;
Axis.Color:=Chart1[0].Color;
LabelsFont.Color:=Chart1[0].Color;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
CopyChartToQRChart(Chart1, QRChart1);
end;
procedure TForm1.CopyChartToQRChart(AChart: TChart; AQRChart: TQRChart);
var i, j: Integer;
begin
CloneChart(AQRChart.Chart, AChart, Self, false);
for i:=0 to AChart.SeriesCount-1 do
if AChart[i].CustomVertAxis<>nil then
for j:=0 to AChart.CustomAxes.Count-1 do
if AChart.CustomAxes[j]=AChart[i].CustomVertAxis then
QRChart1.Chart[i].CustomVertAxis:=QRChart1.Chart.CustomAxes[j];
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Clone TChart to TQRChart
Hi again,
I've moved the TV52016721 ticket to the public tracker.
http://bugs.teechart.net/show_bug.cgi?id=780
Feel free to add your mail to the CC list to be automatically notified when an update arrives.
I've moved the TV52016721 ticket to the public tracker.
http://bugs.teechart.net/show_bug.cgi?id=780
Feel free to add your mail to the CC list to be automatically notified when an update arrives.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |