Problem with metafile (EMF and WMF)

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
dhovden
Newbie
Newbie
Posts: 11
Joined: Fri Oct 05, 2001 4:00 am

Problem with metafile (EMF and WMF)

Post by dhovden » Fri Aug 27, 2010 4:07 pm

Hello,

First, I have to admit that I'm still using TeeChart v5 - it does everything I want it to do (until now) so never felt the need to upgrade. But maybe someone recognises my current problem and has, being cleverer than I, come with a solution.

The story: I have a TChart with one TLineSeries, I copy this to the clipboard in EMF format (or WMF it makes no difference) and paste it in Word or PowerPoint (Office 2003). The paste works fine but when I do Ungroup on the pasted chart the plot itself (i..e the line series) disappears and becomes something small stuck away at the left-hand side of the chart.

Now the really strange bit: this doesn't always happen, sometimes Ungroup works just fine and the line series stays where it should be, ungrouped and all.

I've played with scales, colours etc but haven't been able to find a pattern as yet and am running out of ideas.
So, if anyone has a hint, a suggestion or (even better) a solution, I'd be most grateful.

Regards,
Dag Hovden

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

Re: Problem with metafile (EMF and WMF)

Post by Yeray » Mon Aug 30, 2010 11:06 am

Hi Dag,

I'm not sure to understand how do you exactly set your chart. What do you mean with "Ungroup".
It would be helpful if you could find a way to reproduce the problem consistently and if you could send us a simple example project we can run as-is to reproduce the problem here.
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

dhovden
Newbie
Newbie
Posts: 11
Joined: Fri Oct 05, 2001 4:00 am

Re: Problem with metafile (EMF and WMF)

Post by dhovden » Mon Aug 30, 2010 1:42 pm

Hello,

"Ungroup" is what you can do in MS-Word (or PowerPoint or any Office app), after pasting. For a metafile, like EMF/WMF, the pasted chart is then split up in its component part: labels, axes, data trace, etc and you can edit stuff: change position, font, colour, etc - pretty useful for the end user.

The problem is that in some cases the data trace just disappears (or gets really small) after Ungroup, as if Word somehow messes up the relation between the trace and the X and Y axes.

I'll see if I can come up with a test-project that demonstrates the problem. What makes it awkward it that it isn't consistent, sometimes Ungroup works OK, sometimes not. Producing a project that consistently fails is probably not so easy.

Regards,
Dag Hovden

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

Re: Problem with metafile (EMF and WMF)

Post by Yeray » Wed Sep 01, 2010 11:05 am

Hi Dag,

I've found the unGroup button but it is unavailable for me while the image is selected:
Word 2003.png
Word 2003.png (64.76 KiB) Viewed 6497 times
Am I doing something wrong?
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

dhovden
Newbie
Newbie
Posts: 11
Joined: Fri Oct 05, 2001 4:00 am

Re: Problem with metafile (EMF and WMF)

Post by dhovden » Wed Sep 01, 2010 12:00 pm

Hello Yeray,

"I've found the unGroup button but it is unavailable for me while the image is selected:"

That is strange because I get this (after paste and select image):
Image

Regards,
Dag

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

Re: Problem with metafile (EMF and WMF)

Post by Yeray » Mon Sep 06, 2010 3:08 pm

Hi Dag,

We've seen that your chart seems to be pasted into some other object, maybe a TextBox?
I've inserted a TextBox and pasted the chart into it. Then, in the TextBox contextual menu (not in the Chart image contextual menu) I can see the Group submenu, but all the buttons in it are grayed.

Could you please explain how do you exactly paste the image?
Here is the code I'm using to generate the chart:

Code: Select all

uses series;

procedure TForm1.FormCreate(Sender: TObject);
begin
  with Chart1.AddSeries(TLineSeries) do
    FillSampleValues();

  Chart1.CopyToClipboardMetafile(false);
end;
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

dhovden
Newbie
Newbie
Posts: 11
Joined: Fri Oct 05, 2001 4:00 am

Re: Problem with metafile (EMF and WMF)

Post by dhovden » Tue Sep 07, 2010 9:44 am

Well, it's all pretty straightforward:

after the Copy (in my own app, using EMF), I switch to Word (2003, blank document), press Ctrl-V. Next I right-click the pasted metafile, select "Edit Picture" in the menu (after which the pasted chart has a frame) and then right-click again and select "Grouping" followed by "Ungroup". After the Ungroup, sometimes all is well, sometimes the trace itself disappears.

Regards,
Dag

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

Re: Problem with metafile (EMF and WMF)

Post by Narcís » Wed Sep 08, 2010 2:06 pm

Hi Dag,

I can not reproduce this here using Word 2007. Should I repeat the process many times or try with many different new documents? I'm wondering if it's a Word issue. Do you have any other Word version at hand?

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

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

Re: Problem with metafile (EMF and WMF)

Post by Yeray » Wed Sep 08, 2010 3:40 pm

Hi Dag,

I could reproduce it with a FastLineSeries instead of a LineSeries so I've added it to the defect list to be fixed in future releases (TV52015143).
So a workaround for you could be using a LineSeries.
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

dhovden
Newbie
Newbie
Posts: 11
Joined: Fri Oct 05, 2001 4:00 am

Re: Problem with metafile (EMF and WMF)

Post by dhovden » Thu Sep 09, 2010 12:50 pm

Hello,

"So a workaround for you could be using a LineSeries."

Ah, that's good. I'm using FastLineSeries because I've got lots of data to plot but I'll test and see if LineSeries could be used as well.
Anyway, thanks for your efforts.

Regards,
Dag

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

Re: Problem with metafile (EMF and WMF)

Post by Yeray » Fri Sep 10, 2010 1:50 pm

Hi Dag,

We usually recommend FastLine instead of Line series when many points needs to be drawn as fastest as possible. But sometimes the extra features the Line series has are also needed.
To optimize the speed of your charts, you could try to implement as many tips as possible from the explained in the VCL Real-Time article here. And also here it is a .NET example:

Code: Select all

            public Form1()
            {
                  InitializeComponent();
                  InitializeChart();
            }

            int nrOfSamples = 10000;
            private Steema.TeeChart.Styles.FastLine fastline1;
            private Steema.TeeChart.Styles.FastLine fastline2;
            private System.Diagnostics.Stopwatch stopWatch;

            private void InitializeChart()
            {
                  stopWatch = new System.Diagnostics.Stopwatch();
 
                  tChart1.Aspect.View3D = false;
                  tChart1.Aspect.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed;
 
                  fastline1 = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
                  fastline2 = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
 
                  //pre-assign ChartPens
                  Pen rPen = new Pen(Color.Red);
                  Pen bPen = new Pen(Color.Blue);
                  Steema.TeeChart.Drawing.ChartPen redPen = new Steema.TeeChart.Drawing.ChartPen(tChart1.Chart, rPen);
                  Steema.TeeChart.Drawing.ChartPen bluePen = new Steema.TeeChart.Drawing.ChartPen(tChart1.Chart, bPen);
                  fastline1.LinePen = redPen;
                  fastline2.LinePen = bluePen;
 
                  fastline1.FillSampleValues(nrOfSamples);
                  fastline2.FillSampleValues(nrOfSamples / 2);
 
                  //tChart1.Axes.Left.SetMinMax(-5.0, 5.0);
 
                  tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
            }
 
            void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
            {
                  //calculate elapsed time
                  //stopWatch.Stop();
                  TimeSpan elapsedTime = stopWatch.Elapsed;
                  string total = elapsedTime.TotalSeconds.ToString();
                  label1.Text = "Elapsed time: " + total + " s";
            }
 
            private void button1_Click(object sender, EventArgs e)
            {
                  button1.Enabled = false;
 
                  stopWatch.Reset();
                  stopWatch.Start();
 
                  tChart1.AutoRepaint = false;
 
                  double[] x1 = new double[nrOfSamples];
                  for (int i = 0; i < x1.Length; i++)
                  {
                        x1[i] = i;
                  }
                  double[] x2 = new double[nrOfSamples / 2];
                  for (int i = 0; i < x2.Length; i++)
                  {
                        x2[i] = i;
                  }
                  double[] random1 = new double[nrOfSamples];
                  double[] random2 = new double[nrOfSamples / 2];                             
 
                  for (int i = 0; i < 100; i++)
                  {
                        FillArray(random1);
                        FillArray(random2);
                        fastline1.Add(x1, random1);
                        fastline2.Add(x2, random2);
                        tChart1.AutoRepaint = true;
                        //tChart1.Refresh();
                        Application.DoEvents();
                  }
 
                  stopWatch.Stop();
 
                  button1.Enabled = true;
            }

            private static void FillArray(double[] myArray)
            {
                  Random y = new Random();
                  for (int i = 0; i < myArray.Length; i++)
                  {
                        myArray[i] = y.Next();
                  }
            }
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

Post Reply