TChart.DrawToMetaCanvas question

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
johnnix
Advanced
Posts: 192
Joined: Tue Jul 10, 2007 12:00 am

TChart.DrawToMetaCanvas question

Post by johnnix » Fri Mar 20, 2009 2:53 pm

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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Mar 20, 2009 3:57 pm

Hi johnnix,

Yes, you can set a custom ChartRect:

Code: Select all

  Chart1.CustomChartRect:=true;
  Chart1.ChartRect:=TeeRect(0,0,Chart1.Width,Chart1.Height);
Notice you'll need to include TeCanvas unit to the uses section to be able to use TeeRect method.

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
Image Image Image Image Image Image
Instructions - How to post in this forum

johnnix
Advanced
Posts: 192
Joined: Tue Jul 10, 2007 12:00 am

Post by johnnix » Sat Mar 21, 2009 3:27 pm

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:

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
I uploaded a picture in the attachments newsgroup with the same topic.

Regards

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Mar 23, 2009 3:51 pm

Hi johnnix,

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
Image Image Image Image Image Image
Instructions - How to post in this forum

johnnix
Advanced
Posts: 192
Joined: Tue Jul 10, 2007 12:00 am

Post by johnnix » Tue Mar 24, 2009 6:50 am

Hello Narcis,

I uploaded a sample project in the attachments newsgroup.

Regards

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Mar 24, 2009 3:35 pm

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

johnnix
Advanced
Posts: 192
Joined: Tue Jul 10, 2007 12:00 am

Post by johnnix » Thu Mar 26, 2009 6:39 am

Hello Narcis,

Please see my reply in the attachments newsgroup.

Regards

johnnix
Advanced
Posts: 192
Joined: Tue Jul 10, 2007 12:00 am

Post by johnnix » Mon Mar 30, 2009 7:35 am

Hello Narcis,

Did you understand what I need to do?

Regards

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Mar 30, 2009 7:55 am

Hi johnnix,

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
Image Image Image Image Image Image
Instructions - How to post in this forum

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Mar 31, 2009 12:14 pm

Hi johnnix,

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
Image Image Image Image Image Image
Instructions - How to post in this forum

johnnix
Advanced
Posts: 192
Joined: Tue Jul 10, 2007 12:00 am

Post by johnnix » Wed Apr 01, 2009 5:18 am

Hello Narcis,

Setting the TitleSize seems to do the trick!!!!! Thank you very much for your support.

Post Reply