I am using TeeChart in my asp.net application. I am new to TeeChart and facing an issue as below.
I want to print multiple charts either in single page or in multiple pages. Decision should be taken from print preview window taking care of selected paper size, orientation etc. I have tried by sending multiple charts to print preview. But if I select smaller paper size or zoom up the chart, there is a cut off. It always prints a single page. How do I ensure if all charts are not fit to single page but rather should be printed on multiple pages.
Print multiple charts in either single or multiple pages
Re: Print multiple charts in either single or multiple pages
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Print multiple charts in either single or multiple pages
thanks for reply. Good suggestion by Narcís. but it does not suggest any print preview. And one more point, how do I draw multiple chart in a single PrintPageEventArgs? Again System.Drawing.Printing.PrintDocument document.print(), prints whole document in a single page. How to print multiple page?
Re: Print multiple charts in either single or multiple pages
Hi Biege,
Take a look at this example. I think it should be a good start point to achieve what you are trying to do:
Take a look at this example. I think it should be a good start point to achieve what you are trying to do:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private PrintPreviewDialog printPreviewDialog1 = new PrintPreviewDialog();
private System.Drawing.Printing.PrintDocument printDocument1 = new System.Drawing.Printing.PrintDocument();
private Steema.TeeChart.TChart[] Charts;
private void InitializeChart()
{
Charts = new Steema.TeeChart.TChart[5];
for (int i = 0; i < Charts.Length; i++)
{
Charts[i] = new Steema.TeeChart.TChart();
Charts[i].Parent = this;
Charts[i].Top = 100;
Charts[i].Left = i*Charts[0].Width;
switch (i)
{
case 0: new Steema.TeeChart.Styles.Line(Charts[i].Chart);
break;
case 1: new Steema.TeeChart.Styles.Bar(Charts[i].Chart);
break;
case 2: new Steema.TeeChart.Styles.Pie(Charts[i].Chart);
break;
default: new Steema.TeeChart.Styles.Points(Charts[i].Chart);
break;
}
Charts[i][0].FillSampleValues();
}
printDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(printDocument1_PrintPage);
}
private void button1_Click(object sender, EventArgs e)
{
printPreviewDialog1.Document = printDocument1;
printPreviewDialog1.ShowDialog();
}
void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
Rectangle r;
System.Drawing.Imaging.Metafile m;
for (int i = 0; i < Charts.Length; i++)
{
r = new Rectangle(10, 10 + i*200, 700, 200);
m = Charts[i].Chart.Metafile(Charts[i].Chart, r.Width, r.Height);
e.Graphics.DrawImage(m, r, Charts[i].Chart.ChartBounds, GraphicsUnit.Pixel);
}
}
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Print multiple charts in either single or multiple pages
Yes Biege, this works ok for windows form application. I need similar functionality for my asp.net web application. Is it possible to show windows forms in asp.net?
Re: Print multiple charts in either single or multiple pages
Hello Beige,
I made a simple example using last of TeeChart.Net (version 4) and similar code of Yeray’s posted in previously. Please check next code works as you want.
I hope will helps.
Thanks,
I made a simple example using last of TeeChart.Net (version 4) and similar code of Yeray’s posted in previously. Please check next code works as you want.
Code: Select all
protected void Page_Load(object sender, EventArgs e)
{
InitializeChart();
}
private System.Windows.Forms.PrintPreviewDialog printPreviewDialog1 = new System.Windows.Forms.PrintPreviewDialog();
private System.Drawing.Printing.PrintDocument printDocument1 = new System.Drawing.Printing.PrintDocument();
private void InitializeChart()
{
Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(WebChart1.Chart);
Steema.TeeChart.Styles.Bar bar1= new Steema.TeeChart.Styles.Bar(WebChart2.Chart);
Steema.TeeChart.Styles.Pie pie1 = new Steema.TeeChart.Styles.Pie(WebChart3.Chart);
Steema.TeeChart.Styles.Points points1 = new Steema.TeeChart.Styles.Points(WebChart4.Chart);
line1.FillSampleValues();
bar1.FillSampleValues();
pie1.FillSampleValues();
points1.FillSampleValues();
printDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(printDocument1_PrintPage);
}
void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
System.Drawing.Rectangle r1,r2,r3,r4;
System.Drawing.Imaging.Metafile m1,m2,m3,m4;
//WebChart1
r1 = new System.Drawing.Rectangle(10, 10 + 1 * 200, 700, 200);
m1 = WebChart3.Chart.Metafile(WebChart1.Chart, r1.Width, r1.Height);
e.Graphics.DrawImage(m1, r1, WebChart1.Chart.Chart.ChartBounds, System.Drawing.GraphicsUnit.Pixel);
//WebChart2
r2 = new System.Drawing.Rectangle(10, 10 + 2 * 200, 700, 200);
m2 = WebChart2.Chart.Metafile(WebChart2.Chart, r2.Width, r2.Height);
e.Graphics.DrawImage(m2, r2, WebChart2.Chart.Chart.ChartBounds, System.Drawing.GraphicsUnit.Pixel);
//WebChart3
r3 = new System.Drawing.Rectangle(10, 10 + 3* 200, 700, 200);
m3 = WebChart3.Chart.Metafile(WebChart3.Chart, r3.Width, r3.Height);
e.Graphics.DrawImage(m3, r3, WebChart3.Chart.Chart.ChartBounds, System.Drawing.GraphicsUnit.Pixel);
//WebChart4
r4= new System.Drawing.Rectangle(10, 10 + 4 * 200, 700, 200);
m4 = WebChart3.Chart.Metafile(WebChart4.Chart, r4.Width, r4.Height);
e.Graphics.DrawImage(m4, r4, WebChart4.Chart.Chart.ChartBounds, System.Drawing.GraphicsUnit.Pixel);
}
protected void Button1_Click(object sender, EventArgs e)
{
printPreviewDialog1.Document = printDocument1;
printPreviewDialog1.ShowDialog();
}
Thanks,
Best Regards,
Sandra Pazos / 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 |