TChart.DrawToMetaCanvas question
TChart.DrawToMetaCanvas question
Hello,
I have a TChart object with a series associated with left and bottom axis. I want to plot this TChart in a custom Metafile canvas so that the bottom axis will be drawn in a custom position e.g. at 500 pixels of my metafile canvas. This means that if I draw a line from (0,500) to (300,500) on my metafile canvas this line will touch the bottom axis of my chart. What I noticed is that if I pass a rectangle in the DrawToMetaCanvas procedure the bottom axis is drawn some pixels above the bottom of the rectangle due to the presence of the title and labels. Any ideas please?
Regards
I have a TChart object with a series associated with left and bottom axis. I want to plot this TChart in a custom Metafile canvas so that the bottom axis will be drawn in a custom position e.g. at 500 pixels of my metafile canvas. This means that if I draw a line from (0,500) to (300,500) on my metafile canvas this line will touch the bottom axis of my chart. What I noticed is that if I pass a rectangle in the DrawToMetaCanvas procedure the bottom axis is drawn some pixels above the bottom of the rectangle due to the presence of the title and labels. Any ideas please?
Regards
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi johnnix,
Yes, you can set a custom ChartRect:
Notice you'll need to include TeCanvas unit to the uses section to be able to use TeeRect method.
Hope this helps!
Yes, you can set a custom ChartRect:
Code: Select all
Chart1.CustomChartRect:=true;
Chart1.ChartRect:=TeeRect(0,0,Chart1.Width,Chart1.Height);
Hope this helps!
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 |
Hello,
Thank you for the tip. The plot area now is drawn as wanted but all other elements (axis, labels, chart title) are not positioned correctly. Here is the code I use to create the metafile:
I uploaded a picture in the attachments newsgroup with the same topic.
Regards
Thank you for the tip. The plot area now is drawn as wanted but all other elements (axis, labels, chart title) are not positioned correctly. Here is the code I use to create the metafile:
Code: Select all
chart := TChart.Create(nil);
Chart.CustomChartRect:=true;
Chart.ChartRect:=TeeRect(10,start_y,150,start_y+trunc(total_depth*(h-start_y)/total_depth));
chart.BevelInner :=bvNone;
chart.BevelOuter := bvNone;
series := TLineSeries.Create(chart);
chart.AddSeries(series);
chart.Series[0].Assign(qt_plot.Series[0]); // assign series from other plot
chart.DrawToMetaCanvas(canvas, chart.ChartRect);
chart.free
Regards
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi johnnix,
Could you please send us a simple example project we can run "as-is" to reproduce the problem here?
Thanks in advance.
Could you please send us a simple example project we can run "as-is" to reproduce the problem here?
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 |
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi johnnix,
Thanks for the example project. I'm not sure about what you are trying to obtain here. Could you please explain what you'd like to get? An image would be very helpful.
Thanks in advance.
Thanks for the example project. I'm not sure about what you are trying to obtain here. Could you please explain what you'd like to get? An image would be very helpful.
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 |
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi johnnix,
Yes, we are investigating the issue here. Will get back to you ASAP.
Yes, we are investigating the issue here. Will get back to you ASAP.
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 |
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi johnnix,
Setting TitleSize in your project works fine for us here:
Setting TitleSize in your project works fine for us here:
Code: Select all
procedure TForm10.Button1Click(Sender: TObject);
var chart: TChart;
series: TLineSeries;
begin
chart := TChart.Create(nil);
if checkbox1.Checked then
begin
Chart.CustomChartRect:=true;
Chart.ChartRect:=TeeRect(50,10,300,300);
end;
chart.Assign(plot);
chart.BevelInner :=bvNone;
chart.BevelOuter := bvNone;
series := TLineSeries.Create(chart);
chart.AddSeries(series);
chart.Series[0].Assign(plot.Series[0]); // assign series from other plot
Chart.Axes.Left.TitleSize := -40;
Chart.Axes.Bottom.TitleSize := -20;
chart.DrawToMetaCanvas(image1.canvas, chart.ChartRect);
chart.free ;
image1.Refresh;
end;
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 |