Can we have two charts in the same canvas?

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
brian
Newbie
Newbie
Posts: 4
Joined: Tue Jun 20, 2006 12:00 am

Can we have two charts in the same canvas?

Post by brian » Wed Mar 28, 2007 5:43 pm

Hi All,

I would like to draw the second chart at the top right corner of the first chart's canvas, and then print out this combined chart layout. Can we do it ? Thank you very much for your support.

Bye,
Brian

Edu
Advanced
Posts: 206
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia

Post by Edu » Thu Mar 29, 2007 9:19 am

Hi brian

Yes, you can do it. You have to print the form, you can do something similiar as below code:

Code: Select all

private void button1_Click(object sender, EventArgs e)
        {
            System.Drawing.Printing.PrintDocument document = new System.Drawing.Printing.PrintDocument();

            document.PrintController = new System.Drawing.Printing.StandardPrintController();
            document.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(document_PrintPage);

            document.Print();
        }

        void document_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            Rectangle r1 = new Rectangle(0, 0 , tChart1.Chart.Width , tChart1.Chart.Height );
            Rectangle r2 = new Rectangle(tChart2.Left - tChart1.Left, 0, tChart2.Chart.Width , tChart2.Chart.Height);

            System.Drawing.Imaging.Metafile m = tChart1.Chart.Metafile(tChart1.Chart, r1.Width , r1.Height);
            System.Drawing.Imaging.Metafile m2 = tChart1.Chart.Metafile(tChart2.Chart, r2.Width, r2.Height);

            e.Graphics.DrawImage(m, r1, tChart1.Chart.ChartBounds, GraphicsUnit.Pixel);
            e.Graphics.DrawImage(m2, r2, tChart2.Chart.ChartBounds, GraphicsUnit.Pixel);
        }
We are currently working in v3 and it will include SubChart tool which will make what you request much easier as you will just need to print the parent chart.
Best Regards,
Edu

Steema Support Central
http://support.steema.com/

brian
Newbie
Newbie
Posts: 4
Joined: Tue Jun 20, 2006 12:00 am

Thank you very much

Post by brian » Fri Mar 30, 2007 10:03 pm

Hi Edu,

Thank you very much for your suggestion.

Bye,
Brian

Post Reply