Output Quality (TChart v3.5.3498327368)

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
UserLS
Advanced
Posts: 247
Joined: Wed May 23, 2007 12:00 am

Output Quality (TChart v3.5.3498327368)

Post by UserLS » Tue Sep 01, 2009 10:21 pm

All I am doing is: create a pie chart, show it on my form. Editing is done using the Chart Editor provided by TChart. I am setting Chart.Aspect.SmoothingMode to SmoothingMode.AntiAlias (I did try to set it to SmoothingMode.HighQuality and result was basically the same). I have a button on my form to save the chart as a metafile (so I can include the image into my report). I am using EmfType.EmfPlusOnly option. I am attaching the screen shot of my form and the image file created (I had to save it as PNG for upload, but the quality is the same). The quality of the image is unacceptable (note, that shadows are missing, text is different, let alone the pie itself...). What can be done to improve it?
Attachments
SameChart.png
SameChart.png (32.47 KiB) Viewed 8774 times
ScreenShot.jpg
ScreenShot.jpg (27.71 KiB) Viewed 8720 times

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Output Quality (TChart v3.5.3498327368)

Post by Yeray » Wed Sep 02, 2009 9:35 am

Hi UserLS,

I've tried to obtain a chart similar to yours with the following code:

Code: Select all

        private void InitializeChart()
        {
            chartController1.Chart = tChart1;
            
            tChart1.Aspect.Chart3DPercent = 50;
            tChart1.Aspect.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            tChart1.Header.Text = "This is an example of my graph";
            tChart1.Header.Transparent = false;
            tChart1.Header.Gradient.Visible = true;
            tChart1.Header.Shadow.Visible = true;
            tChart1.Header.Shadow.Height = 10;
            tChart1.Header.Shadow.Width = 10;
            tChart1.Header.Shadow.Color = Color.LightGray;
            tChart1.Header.Shadow.Smooth = true;            
            tChart1.Header.Font.Name = "Gabriola";
            tChart1.Header.Font.Italic = true;
            tChart1.Header.Font.Size = 18;

            tChart1.Legend.Title.Text = "THIS IS MY LEGEND";
            tChart1.Legend.Title.Visible = true;
            tChart1.Legend.Title.Gradient.Visible = true;
            tChart1.Legend.Shadow.Height = 10;
            tChart1.Legend.Shadow.Width = 10;
            tChart1.Legend.Shadow.Color = Color.LightGray;
            tChart1.Legend.Gradient.Visible = true;
            tChart1.Legend.Shadow.Smooth = true;

            Pie pie1 = new Pie(tChart1.Chart);

            pie1.FillSampleValues();
            pie1.Transparency = 50;
            pie1.BevelPercent = 10;
            pie1.EdgeStyle = Steema.TeeChart.Drawing.EdgeStyles.Curved;
            pie1.Shadow.Height = 350;
            pie1.Shadow.Color = Color.LightGray;            
            pie1.Marks.Visible = false;
            pie1.Shadow.Visible = true;            

            tChart1.Aspect.Elevation = 290;            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            tChart1.Export.Image.Metafile.EMFFormat = System.Drawing.Imaging.EmfType.EmfPlusOnly;
            tChart1.Export.Image.Metafile.Save("C:\\tmp\\test.emf");
        }
The result is a metafile that could be probably improved in quality (I've added this to the wish list to be enhanced for further releases [TF02014378]) but I'm not able to reproduce your problem with the shadows. Could you please try it and see if the shadows are correctly exported?
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

UserLS
Advanced
Posts: 247
Joined: Wed May 23, 2007 12:00 am

Re: Output Quality (TChart v3.5.3498327368)

Post by UserLS » Wed Sep 02, 2009 4:24 pm

I could not make your code work for me when I have a dynamically generated chart, which does not have a parent form. Every time it hits the line:

Code: Select all

          tChart1.Export.Image.Metafile.Save("C:\\tmp\\test.emf");
it throws an exception "Parameter is not valid." Instead I have to do the following:

Code: Select all

            PictureBox image;
            ...
            image.Image = chart.Chart.Metafile(new MemoryStream(), chart.Chart, chart.Width, chart.Height, EmfType.EmfPlusOnly);
            image.Image.Save("C:\\tmp\\test.emf");
and that is when I am missing the shadows and the fonts are not right either.
My problem is that I have another form active at the time with the whole report being displayed there. I have to generate the Chart image in memory and insert it into the report. I cannot show another form during this process, but it seems to me, that in order to get an OK quality of the chart image I have to place it onta a form and show it :( ! So, what should I do?

Another observation: I really do not need a file saved on disk, so I did try to save metafile to a memory stream, but I could not use this stream to generate image from it (using Image.FromStream() method).

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Output Quality (TChart v3.5.3498327368)

Post by Narcís » Thu Sep 03, 2009 10:09 am

Hi UserLS,
My problem is that I have another form active at the time with the whole report being displayed there. I have to generate the Chart image in memory and insert it into the report. I cannot show another form during this process, but it seems to me, that in order to get an OK quality of the chart image I have to place it onta a form and show it :( ! So, what should I do?
Ok, this is because you need to set your chart's Chart dimensions before exporting it, for example:

Code: Select all

			myChart.Export.Image.Metafile.EMFFormat = System.Drawing.Imaging.EmfType.EmfPlusOnly;
			myChart.Chart.Width = this.Width;
			myChart.Chart.Height = this.Height;
			myChart.Export.Image.Metafile.Save("C:\\temp\\myChart.emf");
Another observation: I really do not need a file saved on disk, so I did try to save metafile to a memory stream, but I could not use this stream to generate image from it (using Image.FromStream() method).
Maybe you need to set stream's position to zero before reading it. Code below work fine for me here.

Code: Select all

		private void button1_Click(object sender, EventArgs e)
		{
			//tChart1.Export.Image.Metafile.EMFFormat = System.Drawing.Imaging.EmfType.EmfPlusOnly;
			//tChart1.Export.Image.Metafile.Save("C:\\temp\\test.emf");

			myChart.Export.Image.Metafile.EMFFormat = System.Drawing.Imaging.EmfType.EmfPlusOnly;
			myChart.Chart.Width = this.Width;
			myChart.Chart.Height = this.Height;

			System.IO.MemoryStream imageStream = new System.IO.MemoryStream();
			
			myChart.Export.Image.Metafile.Save(imageStream);
			
			imageStream.Position = 0;
			pictureBox1.Image = Image.FromStream(imageStream);
		}	
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

UserLS
Advanced
Posts: 247
Joined: Wed May 23, 2007 12:00 am

Re: Output Quality (TChart v3.5.3498327368)

Post by UserLS » Fri Sep 04, 2009 2:26 pm

Thanks! This works a lot better! As you've mentioned, the quality could be better, but with all the changes you've suggested, our output now is at least not worse (and in some cases better) than the Win32 version.

UserLS
Advanced
Posts: 247
Joined: Wed May 23, 2007 12:00 am

Re: Output Quality (TChart v3.5.3498327368)

Post by UserLS » Tue Sep 08, 2009 2:21 pm

Ok, I did have some problems with the image files, so I tried to go strait to PDF format... The same graph in PDF looks awful (I would attach it, if your site allowed PDF files). Is there any way to make it reasonably good?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Output Quality (TChart v3.5.3498327368)

Post by Narcís » Tue Sep 08, 2009 2:40 pm

Hi UserLS,

Can you please compress the file in a .zip package and attach it here or send it at http://www.steema.net/upload?

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

UserLS
Advanced
Posts: 247
Joined: Wed May 23, 2007 12:00 am

Re: Output Quality (TChart v3.5.3498327368)

Post by UserLS » Tue Sep 08, 2009 5:43 pm

Here it is!
Attachments
SameGraph.zip
(11.3 KiB) Downloaded 435 times

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Output Quality (TChart v3.5.3498327368)

Post by Narcís » Wed Sep 09, 2009 8:37 am

Hi UserLS,

Thanks for the file. I'm afraid the problem is that TeeChart's PDF export doesn't support transparency. This is already in the wish list (TF02013896) to be enhanced for future releases. In the meantime a workaround is exporting the chart to an image and then convert it to a PDF file.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply