Page 1 of 1

Multiple Charts

Posted: Thu Apr 05, 2007 6:33 pm
by 9643227
Dear TeeChart Support:

In my project, I need to plot multiple graphs on the same Form. Each of these graphs should have its own axes and walls and the program should be able to export them to a file (e.g. JPEG) and to print them out WYSIWYG. It seems to me that there are two ways to archieve this, but both have some problems that I need your help with.

A. The first way is to use a single TChart object with one set of customized axes and walls for each sub-graph. Problems are:

1. How do I create customized Walls (Left, Rigth, Bottom, and Back), for each sub-graph in the same TChart object?

2. According to the doc, customized Axes are supported only for Left, Top, Bottom, and Right axes, does this mean that all sub-graphs in the same TChat object have to share the same Depth and DepthTop axes?

B. The second way is to use multiple TChart objects on the same Form. Problems are:

1. How do I export multiple TCharts as shown on the same Form to a file (e.g. JPEG) WYSIWYG?

2. How do I print multiple TCharts as shown on the same windows Form WYSIWYG?

I would also appreciate if you could suggest me a better solution than the two mentioned above. Thank you very much for your help.

Jeff

Posted: Tue Apr 10, 2007 8:43 am
by narcis
Hi Jeff,

Please find below the answers to your questions:
A. The first way is to use a single TChart object with one set of customized axes and walls for each sub-graph. Problems are:

1. How do I create customized Walls (Left, Rigth, Bottom, and Back), for each sub-graph in the same TChart object?
This is not possible for now. You'll be able to do that using SubChart tool which has been implemented in TeeChart for .NET v3 Beta.
2. According to the doc, customized Axes are supported only for Left, Top, Bottom, and Right axes, does this mean that all sub-graphs in the same TChat object have to share the same Depth and DepthTop axes?
This is not possible for now. I've added your request to our wish-list to be considered for inclusion in future releases.

B. The second way is to use multiple TChart objects on the same Form. Problems are:

1. How do I export multiple TCharts as shown on the same Form to a file (e.g. JPEG) WYSIWYG?
If you are using .NET 2.0 you can add a button to your WinForm and add the following code to it:

Code: Select all

  private void button1_Click(object sender, EventArgs e)
  {
   string fileName = @"C:\temp\allchart.bmp";
   Rectangle rect = new Rectangle(0, 0, this.Width, this.Height);
   Bitmap bmp = new Bitmap(rect.Width, rect.Height);
   DrawToBitmap(bmp, rect);
   bmp.Save(fileName);
  }
To obtain a Bitmap from a TChart you can use tChart1.Bitmap method. You can also obtain a chart's rectangle using tChart1.Chart.ChartRect.
2. How do I print multiple TCharts as shown on the same windows Form WYSIWYG?
You could use a PrintDocument as shown in the messages below:

http://www.teechart.net/support/viewtopic.php?t=5490
http://www.teechart.net/support/viewtopic.php?t=5756

Posted: Tue Apr 10, 2007 7:03 pm
by 9643227
Thanks NarcĂ­s! Could you also supply a sample code that exports multiple TCharts on a Windows Form to a JPEG file?

Jeff

Posted: Wed Apr 11, 2007 8:09 am
by narcis
Hi Jeff,

In that case you just need to do something like this:

Code: Select all

		private void button1_Click(object sender, EventArgs e)
		{
			//string fileName = @"C:\temp\allchart.bmp";
			string fileName = @"C:\temp\allchart.jpg";
			Rectangle rect = new Rectangle(0, 0, this.Width, this.Height);
			Bitmap bmp = new Bitmap(rect.Width, rect.Height);
			DrawToBitmap(bmp, rect);
			//bmp.Save(fileName);
			bmp.Save(fileName, System.Drawing.Imaging.ImageFormat.Jpeg);
		}