Page 1 of 1
Can we have two charts in the same canvas?
Posted: Wed Mar 28, 2007 5:43 pm
by 9641633
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
Posted: Thu Mar 29, 2007 9:19 am
by 9348258
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.
Thank you very much
Posted: Fri Mar 30, 2007 10:03 pm
by 9641633
Hi Edu,
Thank you very much for your suggestion.
Bye,
Brian