Page 1 of 1
Output Quality (TChart v3.5.3498327368)
Posted: Tue Sep 01, 2009 10:21 pm
by 14045174
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?
Re: Output Quality (TChart v3.5.3498327368)
Posted: Wed Sep 02, 2009 9:35 am
by yeray
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?
Re: Output Quality (TChart v3.5.3498327368)
Posted: Wed Sep 02, 2009 4:24 pm
by 14045174
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).
Re: Output Quality (TChart v3.5.3498327368)
Posted: Thu Sep 03, 2009 10:09 am
by narcis
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);
}
Re: Output Quality (TChart v3.5.3498327368)
Posted: Fri Sep 04, 2009 2:26 pm
by 14045174
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.
Re: Output Quality (TChart v3.5.3498327368)
Posted: Tue Sep 08, 2009 2:21 pm
by 14045174
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?
Re: Output Quality (TChart v3.5.3498327368)
Posted: Tue Sep 08, 2009 2:40 pm
by narcis
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.
Re: Output Quality (TChart v3.5.3498327368)
Posted: Tue Sep 08, 2009 5:43 pm
by 14045174
Here it is!
Re: Output Quality (TChart v3.5.3498327368)
Posted: Wed Sep 09, 2009 8:37 am
by narcis
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.