Page 1 of 1

Problem with metafile (EMF and WMF)

Posted: Fri Aug 27, 2010 4:07 pm
by 5887836
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

Re: Problem with metafile (EMF and WMF)

Posted: Mon Aug 30, 2010 11:06 am
by yeray
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.

Re: Problem with metafile (EMF and WMF)

Posted: Mon Aug 30, 2010 1:42 pm
by 5887836
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

Re: Problem with metafile (EMF and WMF)

Posted: Wed Sep 01, 2010 11:05 am
by yeray
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 6502 times
Am I doing something wrong?

Re: Problem with metafile (EMF and WMF)

Posted: Wed Sep 01, 2010 12:00 pm
by 5887836
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

Re: Problem with metafile (EMF and WMF)

Posted: Mon Sep 06, 2010 3:08 pm
by yeray
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;

Re: Problem with metafile (EMF and WMF)

Posted: Tue Sep 07, 2010 9:44 am
by 5887836
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

Re: Problem with metafile (EMF and WMF)

Posted: Wed Sep 08, 2010 2:06 pm
by narcis
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.

Re: Problem with metafile (EMF and WMF)

Posted: Wed Sep 08, 2010 3:40 pm
by yeray
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.

Re: Problem with metafile (EMF and WMF)

Posted: Thu Sep 09, 2010 12:50 pm
by 5887836
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

Re: Problem with metafile (EMF and WMF)

Posted: Fri Sep 10, 2010 1:50 pm
by yeray
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();
                  }
            }