Page 1 of 1

Printing Multiple Charts

Posted: Wed Jan 31, 2007 11:24 am
by 8127541
Hi Everyone,

How do I print multiple charts on 1 page extending over more than one page?

I have a radial/pie chart that represents a set of values. The requirement is to display a series of radial/pie chart on screen each with their own set of values. The second requirement is to print the series of charts.

I have successfully manage to draw a series of charts on a panel in my application in runtime, but can't print them in equal fashion. Any ideas?

Regards,
Casper JH Erasmus

Posted: Wed Jan 31, 2007 1:02 pm
by narcis
Hi Casper,

Have you tried doing something as in the All Features\Welcome !\Chart styles\Standard\Pie\Multiple Pies example in the features demo? You'll find the demo at TeeChart's program group.

Posted: Fri Feb 02, 2007 6:34 am
by 8127541
Narcis,

I've studied the example, but this is not what I have to do. My charts are drawn at runtime since do not know beforehand how many charts has to be drawn. How would I draw e.g. 50 pies and be able to view all of them on screen. How would I print them since it looks like whatever is drawn on screen is printed the same way, like WYSIWYG.

Regards,
Casper

Posted: Fri Feb 02, 2007 11:27 am
by narcis
Hi Casper,

Could you please send us a simple example project (e.g.: two pies) we can run "as-is" to reproduce the problem here?

You can post your files at news://www.steema.net/steema.public.attachments newsgroup or at the upload page.

Thanks in advance.

Posted: Mon Feb 05, 2007 8:51 am
by 8127541
Narcis,

I've uploaded a simple projecton the upload page. Try the following:

1. Run the project.
2. Resize the form so that only two pies are shown, then click the print button.
3. Two piese will be shown in print preview.
4. Resize the form so that 3 pies are shown.
5. Click print button, 3 pies are shown in print preview.
This to me means that whatever isshown on screen is printed, i.e. WYSIWIG.

My problem is that is I were to print 50 pies, not all of them will show on screen, so how would I make sure that I print all 50 pies. I cannot make the pies too small, cause I need to have the detail be clear enough.

Thanks

Posted: Mon Feb 05, 2007 4:39 pm
by narcis
Hi Casper,

Thanks for the example.

TeeChart prints only what is within the TeeChart object when the print dialog is launched. To print what's in the chart but not displayed all you have to do is to export the chart at the size (or with the settings) at which everything is displayed. To do this you will have to create your own PrintDocument and not use the one that TeeChart creates. This applied to your example is this:

Code: Select all

		private void button1_Click(object sender, System.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 r = new Rectangle(10, 10, 700, 200);
			System.Drawing.Imaging.Metafile m = tChart1.Chart.Metafile(tChart1.Chart, r.Width, r.Height);
			
			e.Graphics.DrawImage(m, r, tChart1.Chart.ChartBounds, GraphicsUnit.Pixel);
		}

Posted: Mon Feb 12, 2007 7:01 am
by 8127541
Narcis,

tahnks very much for the solution. I've uploaded "pietest2.zip" where I'm trying to plot multiple pies during run time. When the chart is displayed the first time a couple of pies is shown, but when I want to resize the form to see more pies, all my pies disappear. Am I doing it wrong or is there a way to scroll the chart to be able to see all the pies?

Thanks
Regards,

Posted: Mon Feb 12, 2007 8:48 am
by narcis
Hi Casper,

The problem is that xpos and ypos are not reseted after each time the chart is drawn. You can solve this changing your BeforeDrawValues to something like this:

Code: Select all

		private void pie_BeforeDrawValues(object sender, Steema.TeeChart.Drawing.Graphics3D g)
		{
			xpos = 10+100*tChart1.Series.IndexOf((Steema.TeeChart.Styles.Series)sender);
			ypos = 10+200*tChart1.Series.IndexOf((Steema.TeeChart.Styles.Series)sender);
			this.tChart1.Chart.ChartRect = new Rectangle(xpos,ypos,200, 100);
		}
Or reset xpos and ypos in the AfterDraw event:

Code: Select all

		private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
		{
			xpos=10;
			ypos=10;
		}

Similar needs

Posted: Wed May 02, 2007 9:35 pm
by 8739068
I have a similar need to print multiple charts. Mine need is going to be a list a different types of charts.

I tried to find the example that Narcis said he uploaded. I cannot find this file. Can someone point me to this example?

Mike

Re: Printing Multiple Charts

Posted: Fri Feb 19, 2010 9:54 am
by 9641714
I have same question as Mike. How do I get the pietest2.zip file. One more point I want to ask, how do I attach multiple chart in document_PrintPage function deescribed by Narcis.

Re: Printing Multiple Charts

Posted: Fri Feb 19, 2010 3:37 pm
by yeray
Hi Mike and Biege,

Note that Casper was trying to print different pie series but all them from the same chart. If I'm not wrong, what you are trying to do is to print multiple independent charts into the same page.
Please, take a look at my response here where printing different charts is being discussed.