Saving chart into image

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

Saving chart into image

Post by UserLS » Wed May 12, 2010 9:59 pm

I am trying to include chart into my report. I've tried a few different image options, but seems to me all of them have the same problems:
  • if I set my graph to NOT SHOW ANY BORDERS, then you guys are adding a black border around my graph anyway. Is there any way to produce an image file with chart and without border?
  • if I set my chart with transparent background (or try to use shadow for the whole graph), in resulting image areas, that supposed to be transparent, are black!
  • if I set my chart.Panel.Shadow.Visible = true and save it as image - the shadow is there (yes, the transparent parts are black, but this is not the point here). Now, if I set chart.Panel.Shadow.Smooth = true, save this graph into an image file - the whole shadow is gone now!
Again, all these problems are critical for us, since we do need graphs so we can include them into reports.

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

Re: Saving chart into image

Post by Yeray » Fri May 14, 2010 3:22 pm

Hi UserLS,

As you'll see here these are known issues. In the same thread there are some workarounds and it is also knows that exporting to metafile works fine:

Code: Select all

tChart1.Export.Image.Metafile.CopyToClipboard();
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: Saving chart into image

Post by UserLS » Sat May 15, 2010 5:00 am

I wish it was true about metafile - this is our preferred format, but... try, for example, to set grid lines as following:
Width = 1
Style = DashStyle.Dot
EndCap = Linecap.Round
DashCap = DashCap.Roound
Now, save this chart into metafile and explain why grid lines are not straight (to see it clearly you may need to zoom in a little)?

Smooth shadows are not coming through at all, while other options (like edge styles on pie) are not drawn properly. Header seems to be drawn twice, and if I zoom in/out it turns out that two versions of header text have different widths. I can continue this list, but the point is: this format is not ready for its prime time.

Besides, you have another issue with metafiles: its size. The file created is huge, especially if I am using EmfPlusOnly or EmfPlusDual options. We tried to include it into our report and then send report to printer - it takes 5 - 10 minutes, before the printer starts printing! With PNG format the delay is not noticeable at all.

As to other image formats, setting bevel as you have shown in other post, does not work for us (the other properties you've changed there I cannot touch - they are controlled by my users and I am not supposed to change them. Bevel we never use and it always stays set to None.). But good news - I think setting UseBuffer to false does take care of transparent issue. One question though: IDE hints me that this property is marked as obsolete, but it did not tell me what I am supposed to use instead.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Saving chart into image

Post by Sandra » Mon May 17, 2010 11:15 am

Hello UserLs,
I wish it was true about metafile - this is our preferred format, but... try, for example, to set grid lines as following:
Width = 1
Style = DashStyle.Dot
EndCap = Linecap.Round
DashCap = DashCap.Roound
Now, save this chart into metafile and explain why grid lines are not straight (to see it clearly you may need to zoom in a little)?
I could reproduce it and I have added it to the wish list with number[TF02014886]. We will try to fix for next maintenance releases of TeeChart .Net. Also I found a workaround, that I think you could use for solve your problem:

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:\\teeChart1.emf"); 

         }
Smooth shadows are not coming through at all, while other options (like edge styles on pie) are not drawn properly. Header seems to be drawn twice, and if I zoom in/out it turns out that two versions of header text have different widths.
I could reproduce your problems and I added these in bug (TF02014886), because I think that they all are related. In the case of pie I could reproduce your problem and I have added it in bug list report whit number [TF02014894]. We will try to fix these for next maintenance releases of TeeChart.net.
I can continue this list, but the point is: this format is not ready for its prime time.
If do you think there are more issues in this area, we would like to know about them. Identifying existing problems will help us enhancing current functionality.
Besides, you have another issue with metafiles: its size. The file created is huge, especially if I am using EmfPlusOnly or EmfPlusDual options. We tried to include it into our report and then send report to printer - it takes 5 - 10 minutes, before the printer starts printing! With PNG format the delay is not noticeable at all.
I couldn't reproduce your problem using last version of TeeChart .Net. Please, could you send us a simple example or explain exactly which steps we can follow for reproduce the problem here?
Also, could you say us what is your version of TeeChart .Net?
As to other image formats, setting bevel as you have shown in other post, does not work for us (the other properties you've changed there I cannot touch - they are controlled by my users and I am not supposed to change them. Bevel we never use and it always stays set to None.). But good news - I think setting UseBuffer to false does take care of transparent issue. One question though: IDE hints me that this property is marked as obsolete, but it did not tell me what I am supposed to use instead.
You should use property BufferStyle. If you want that behaves as tChart1.Graphics3D.UseBuffer = false; you can do:

Code: Select all

     tChart1.Graphics3D.BufferStyle = Steema.TeeChart.Drawing.BufferStyle.None;
and If you want that behaves as tChart1.Graphics3D.UseBuffer = true;

Code: Select all

     tChart1.Graphics3D.BufferStyle = Steema.TeeChart.Drawing.BufferStyle.OptimizedBuffer;
I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / 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: Saving chart into image

Post by UserLS » Mon May 24, 2010 5:55 pm

If do you think there are more issues in this area, we would like to know about them. Identifying existing problems will help us enhancing current functionality.
Well, I was really surprised to see that. You know, I bought your product not for the opportunity to test it (what is your responsibility) but rather to be able to use it. The problems I've listed, I just found by trying to use metafile format for a few minutes (after which I just gave up since there was not a single chart saved into this format without any obvious problems). Further testing I'll leave for you guys, after all, it is your product.
Besides, you have another issue with metafiles: its size. ...
I couldn't reproduce your problem using last version of TeeChart .Net. Please, could you send us a simple example or explain exactly which steps we can follow for reproduce the problem here?
Also, could you say us what is your version of TeeChart .Net?
I am not sure what is it exactly you could not reproduce... I am using the latest released version of TChart 2010. Go to Chart Editor, create a simple bar graph, fill it with a few random values. Now go to the Export page and save you chart as .PNG format (in my case, file size is 37KB). Saving the same chart as metafile produces files with sizes from 1,432KB to 3,883BK depending on EMF type - which in worst case was about 105 times bigger than .PNG! Doing the same test with more sophisticated pie chart resulted in .PNG file of 58KB and metafiles 7,869KB (for EmfOnly) and 20,246KB (for EmfPlusOnly) - which is about 350 times bigger than .PNG! Including these monsters inside our reports (which are complicated enough as they are) is a very bad idea!

This problem is very critical for us. We transitioned from Delphi (where metafiles worked just fine) to .NET this year. Now my users are stuck with either .PNG, .JPEG or other similar firmats, that do not produce required quality and have problems, like with the border, that have no work around for them. And you know about it for about 18 months and choose not to fix it asap (so there is no hope, you will ever fix it). From other side there are metafiles, with tons of bugs, huge sizes which makes them even less usable... So, the question is: how can we save a chart into our reports (if I cannot do this simple task - why bother at all setting it up?)

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Saving chart into image

Post by Sandra » Tue May 25, 2010 11:27 am

Hello UserLs,
I am not sure what is it exactly you could not reproduce... I am using the latest released version of TChart 2010. Go to Chart Editor, create a simple bar graph, fill it with a few random values. Now go to the Export page and save you chart as .PNG format (in my case, file size is 37KB). Saving the same chart as metafile produces files with sizes from 1,432KB to 3,883BK depending on EMF type - which in worst case was about 105 times bigger than .PNG! Doing the same test with more sophisticated pie chart resulted in .PNG file of 58KB and metafiles 7,869KB (for EmfOnly) and 20,246KB (for EmfPlusOnly) - which is about 350 times bigger than .PNG! Including these monsters inside our reports (which are complicated enough as they are) is a very bad idea!
I couldn't reproduce your problem using next code:

Code: Select all

 public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }
        private void InitializeChart()
        {
            tChart1.Clear();
            tChart1.Width = 800;
            tChart1.Height = 600;

            Steema.TeeChart.Styles.Bar bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
            bar1.FillSampleValues();

            tChart1.Export.Image.PNG.Save("c:\\teeChart1.png");

            tChart1.Export.Image.Metafile.EMFFormat = System.Drawing.Imaging.EmfType.EmfOnly;
            tChart1.Export.Image.Metafile.Save("c:\\teeChartEmfOnly.emf");

            tChart1.Export.Image.Metafile.EMFFormat = System.Drawing.Imaging.EmfType.EmfPlusDual;
            tChart1.Export.Image.Metafile.Save("c:\\teeChartEmfPlusDual.emf");

            tChart1.Export.Image.Metafile.EMFFormat = System.Drawing.Imaging.EmfType.EmfPlusOnly;
            tChart1.Export.Image.Metafile.Save("c:\\teeChartEmfPlusOnly.emf"); 
        }
I have obtained 4 files with next size:
teeChart1(14KB)
teeChart1EmfOnly(95KB)
teeChart1EmfPlusDual(119KB)
teeChart1EmfPlusOnly(20kB)

Please, could you check if using previous code, your problem still appears? Can you modify it so that we can reproduce the issue here?
This problem is very critical for us. We transitioned from Delphi (where metafiles worked just fine) to .NET this year. Now my users are stuck with either .PNG, .JPEG or other similar firmats, that do not produce required quality and have problems, like with the border, that have no work around for them. And you know about it for about 18 months and choose not to fix it asap (so there is no hope, you will ever fix it). From other side there are metafiles, with tons of bugs, huge sizes which makes them even less usable... So, the question is: how can we save a chart into our reports (if I cannot do this simple task - why bother at all setting it up?)
I have found following bugs you reported about exporting and have not been fixed yet:
TF02014886,TF02014894,TF02014868,TF02014758,TF02014378,TF02013896
And I have found the following which have already been fixed:
TF02014764,TF02013790
Could you please confirm if previous bugs are the ones you mention?

Also notice that most issues on the list above have been reported during last 2 months. Only TF02014378 (September 2009) and TF02013896 (February 2009) are older, 15 months the most.

Thanks,
Best Regards,
Sandra Pazos / 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: Saving chart into image

Post by UserLS » Wed May 26, 2010 4:54 pm

Ok, I think I know the difference. Attached you'll find 2 sets of files. First is using rather simple pie chart. The EmfOnly format as you can see is useless, our PDF creator library does not understand EmfDualPlus format. So we are left with EmfPlusOnly, which is 12 times bigger than the PNG file.
Simple Pie.zip
(160.24 KiB) Downloaded 644 times
Now, I have "dressed up" the chart a little: added gradients, shadows... The PNG file grew a little, which is fine. But the EmfPlusOnly metafile (the only one I can use) is now 4 times bigger than it was, or 33 times bigger than corresponding PNG file! Similar chart saved in Delphi produced metafiles comparable in size with PNG files.
Pie With Gradients.zip
(423.33 KiB) Downloaded 635 times
By the way, this example demonstrates a few other problems with this format (fuzzy text and borders, stray shapes and extra font shadows to name a few).

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Saving chart into image

Post by Sandra » Thu May 27, 2010 9:52 am

Hello UserLs,

Thanks, for your image. I have tried to reproduce your problem, but in one case only (EmfPlusDual) I have seen it. Please, you could modify next code, because we can try to reproduce your problem for each exported image, using same code that you.

Also, if you prefer, could export your Chart with template mode (file .ten) and attaches it to thread, because we have same chart that you and we can try to reproduce your problem exactly here.

Code: Select all

   Steema.TeeChart.Styles.Pie pie;
        private void InitializeChart()
        {
            tChart1.Width =  800;
            tChart1.Height =600;

            pie = new Steema.TeeChart.Styles.Pie(tChart1.Chart);
            pie.FillSampleValues();
            pie.EdgeStyle = Steema.TeeChart.Drawing.EdgeStyles.Curved;
            pie.BevelPercent = 15;
            pie.Shadow.Visible = true;
        
            pie.Shadow.Visible = true;
            pie.Shadow.Width = 3;
            pie.Circled = true;

            tChart1.Header.Visible = true;
            tChart1.Header.Transparent = false;
            tChart1.Header.ShapeStyle = Steema.TeeChart.Drawing.TextShapeStyle.RoundRectangle;
            tChart1.Header.Pen.Width = 5;

            tChart1.Header.Font.Size = 15;
            tChart1.Header.Font.Color = Color.Black;

            tChart1.Header.Gradient.Visible = true;
            tChart1.Header.Gradient.StartColor = Color.Yellow;
            tChart1.Header.Gradient.EndColor = Color.White;
            tChart1.Header.Gradient.MiddleColor = Color.Yellow;
            tChart1.Header.Gradient.Style.Visible = true;
            tChart1.Header.Gradient.Style.Direction = Steema.TeeChart.Drawing.PathGradientMode.Radial;
            tChart1.Header.Shadow.Visible = true;

            tChart1.Panel.Shadow.Visible = true;
            tChart1.Panel.Shadow.Width = 10;
            tChart1.Panel.Shadow.Color = Color.Black;
            tChart1.Panel.BorderPen.Visible = true;
            tChart1.Panel.BorderPen.Width = 7;
            tChart1.Panel.BorderPen.Color = Color.Blue;
            tChart1.Panel.BorderRound = 4;

            tChart1.Draw();

            tChart1.Export.Image.PNG.Save("c:\\teeChart1.png");

            tChart1.Export.Image.Metafile.EMFFormat = System.Drawing.Imaging.EmfType.EmfOnly;
            tChart1.Export.Image.Metafile.Save("c:\\teeChartEmfOnly.emf");

            tChart1.Export.Image.Metafile.EMFFormat = System.Drawing.Imaging.EmfType.EmfPlusDual;
            tChart1.Export.Image.Metafile.Save("c:\\teeChartEmfPlusDual.emf");

            tChart1.Export.Image.Metafile.EMFFormat = System.Drawing.Imaging.EmfType.EmfPlusOnly;
            tChart1.Export.Image.Metafile.Save("c:\\teeChartEmfPlusOnly.emf"); 
        }
Thanks,
Best Regards,
Sandra Pazos / 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: Saving chart into image

Post by UserLS » Thu May 27, 2010 10:09 pm

I have no code to provide - I just setup those charts using your editor. Here, in ZIP files attached, I have saved the same chart at a template, PNG image and all 2 variations of metafiles.
Charts 1.zip
(464.93 KiB) Downloaded 635 times
Charts 2.zip
(498.21 KiB) Downloaded 621 times
I am using the latest released version of TChart and I am getting the same results on both XP and Vista environments. I did try to upload the EmfPlusOnly file as well, but even zipped up, the file is too big and your site does not allow it to be uploaded.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Saving chart into image

Post by Sandra » Fri May 28, 2010 9:36 am

Hello UserLs,

Thanks, for your example. I have added your issue (TF02014916) to be enhanced for future releases.

Thanks,
Best Regards,
Sandra Pazos / 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