Changed behavior in legend

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Uli
Newbie
Newbie
Posts: 80
Joined: Thu Apr 22, 2010 12:00 am

Changed behavior in legend

Post by Uli » Mon Jun 21, 2010 12:30 pm

Hi,

due to the last discovered problem http://www.teechart.net/support/viewtop ... =4&t=11243 concerning wrong axis scaling I immediately checked the new release (Build 4.0.2010.27963, it was published a few minutes after that posting).

This earlier posting is related to a strange axis scaling and therefore I will not add the new problem to this thread. But there you can see how the legend appears with the old release http://www.teechart.net/support/viewtop ... =4&t=11243

When I now open the same *.ten file (it's contained in the *.zip of the above URL) in my application compiled with the newest release it looks so:
test_2.jpg
test_2.jpg (43.28 KiB) Viewed 23408 times
The black legend items text disappeared (the white text is due to another bug explained below)

The reason is:
In order to get sub- and superscripts I go the following way:
- creating custom rich text for legend items
- setting the "regular" legend font to color.transparent but the same size as in my "custom" rich text
- drawing the "custom" legend items in a function called from within the TChart.AfterDraw event using "regular" items properties:

Code: Select all

        X = MyChart.Legend.Items(series).Left
        Y = MyChart.Legend.Items(series).Top
And here is the error now: Both X and Y are zero in the application compiled with the new TeeChart release.

You can easiliy check it out:

Code: Select all

    Dim lineser As Steema.TeeChart.Styles.Line
    Dim lineser2 As Steema.TeeChart.Styles.Line

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        lineser = New Steema.TeeChart.Styles.Line(TChart1.Chart)
        lineser.FillSampleValues()
        lineser2 = New Steema.TeeChart.Styles.Line(TChart1.Chart)
        lineser2.FillSampleValues()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        TChart1.Legend.CustomPosition = True
        TChart1.Legend.Color = Color.Transparent
        TChart1.Legend.Font.Color = Color.Transparent
        TChart1.Export.Image.Metafile.CopyToClipboard()
        Dim x As String = TChart1.Legend.Items(0).Left.ToString
        MsgBox(x)
    End Sub

    Private Sub TChart1_AfterDraw(ByVal sender As System.Object, ByVal g As Steema.TeeChart.Drawing.Graphics3D) Handles TChart1.AfterDraw
        Dim x As String = TChart1.Legend.Items(0).Left.ToString
        MsgBox(x)
    End Sub
And another bug becomes visible (the code in Button1_Click is to follow this): The image above was exported as metafile to clipboard:

Code: Select all

ActChildForm.Chart1.Export.Image.Metafile.CopyToClipboard()
and then pasted into MS paint.
You can easily see that the "regular" legends font color (which was set to transparent) is not transparent ***.

This error occurs during metafile export since a screen copy (by means of Windows 7 snipping tool) results in this image:
test_3.jpg
test_3.jpg (33.61 KiB) Viewed 23416 times
Here the "regular" legend font seems to be really transparent.
Please note: The file extension ".fxy" I use in tradition of the old application which shall be replaced by the new one with TeeChart. But the *.fxy files are native *.ten files with no attempts of extending serialization.

What to do?

Uli


***if you can see it not then your monitor settings may be not appropriate: You could increase the contrast in the image editor in order to see the effect.

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

Re: Changed behavior in legend

Post by Sandra » Tue Jun 22, 2010 11:34 am

Hello Uli,
The black legend items text disappeared (the white text is due to another bug explained below)
I could reproduce it and I have added in bug report list with number [TF02014990]. We will try to fix it with next versions of TeeChart .Net.
The reason is:
In order to get sub- and superscripts I go the following way:
- creating custom rich text for legend items
- setting the "regular" legend font to color.transparent but the same size as in my "custom" rich text
- drawing the "custom" legend items in a function called from within the TChart.AfterDraw event using "regular" items properties:

Code: Select all
X = MyChart.Legend.Items(series).Left
Y = MyChart.Legend.Items(series).Top
And here is the error now: Both X and Y are zero in the application compiled with the new TeeChart release.
I test your code with previous version of TeeChart.Net and last version and you are right, in last version X and Y values are zero. I have added it in bug report list with number [TF02014992]. We will try to fix it for next maintenances releases.
And another bug becomes visible (the code in Button1_Click is to follow this):
The image above was exported as metafile to clipboard:
ActChildForm.Chart1.Export.Image.Metafile.CopyToClipboard()
and then pasted into MS paint.
You can easily see that the "regular" legends font color (which was set to transparent) is not transparent ***.
I think that is a problem of Buffer, I recommend that use next lines of Code:

Code: Select all

TChart1.Legend.CustomPosition = True
        TChart1.Legend.Font.Color = Color.Transparent
        TChart1.Graphics3D.BufferStyle = Steema.TeeChart.Drawing.BufferStyle.OptimizedBuffer
        TChart1.Export.Image.Metafile.CopyToClipboard()
Please, could you check if previous code works as you want?

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

Uli
Newbie
Newbie
Posts: 80
Joined: Thu Apr 22, 2010 12:00 am

Re: Changed behavior in legend

Post by Uli » Tue Jun 22, 2010 11:57 am

Hi Sandra,

do you have a workaround in order to get the legend.items.top and left properties?
Please, could you check if previous code works as you want?
I added the line

Code: Select all

TChart1.Graphics3D.BufferStyle = Steema.TeeChart.Drawing.BufferStyle.OptimizedBuffer
to the code sample in my initial message. After pasting the image into MS Paint the white legend item text is still visible. So this code is not the solution.

Regards

Uli

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Re: Changed behavior in legend

Post by Christopher » Wed Jun 23, 2010 8:59 am

Uli,
Uli wrote: When I now open the same *.ten file (it's contained in the *.zip of the above URL) in my application compiled with the newest release it looks so:
test_2.jpg
The black legend items text disappeared (the white text is due to another bug explained below)
Try:

Code: Select all

tChart1.Legend.Font.Color = Color.Black;

having imported the file.
Uli wrote: And here is the error now: Both X and Y are zero in the application compiled with the new TeeChart release.
Try:

Code: Select all

    private Line line1, line2;

    private void InitializeChart()
    {
      line1 = new Line(tChart1.Chart);
      line2 = new Line(tChart1.Chart);
      line1.FillSampleValues();
      line2.FillSampleValues();
    }

    private void button1_Click(object sender, EventArgs e)
    {
      tChart1.Legend.CustomPosition = true;
      tChart1.Legend.Items.Custom = true;

      tChart1.Draw();

      MessageBox.Show(tChart1.Legend.Items[0].Left.ToString());
    }
Uli wrote: And another bug becomes visible (the code in Button1_Click is to follow this): The image above was exported as metafile to clipboard:
Try:

Code: Select all

tChart1.Export.Image.PNG.CopyToClipboard();
Uli wrote: What to do?
Good question! ;-)
Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/

Uli
Newbie
Newbie
Posts: 80
Joined: Thu Apr 22, 2010 12:00 am

Re: Changed behavior in legend

Post by Uli » Wed Jun 23, 2010 9:21 am

Hi Christopher,
Uli wrote:When I now open the same *.ten file (it's contained in the *.zip of the above URL) in my application compiled with the newest release it looks so:
test_2.jpg

The black legend items text disappeared (the white text is due to another bug explained below)
Try:

Code: Select all
tChart1.Legend.Font.Color = Color.Black;
That is a misunderstanding, please see my first post: The "black legend items text" is my "custom item text" (a rich text format string) which should be drawn instead of the "regular TeeChart items" in the AfterDraw events. The white text is that of the regular items for which the legend font was set to color.transparent. It's explained above in more detail. So with your proposal only the "regular items" would become visible - the opposite of my intention.

Again: What to do?

Best regards

Uli

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

Re: Changed behavior in legend

Post by Sandra » Wed Jun 23, 2010 12:54 pm

Hello Uli,
to the code sample in my initial message. After pasting the image into MS Paint the white legend item text is still visible. So this code is not the solution.
You could use solution that Christopher suggest (tChart1.Export.PNG.CopyToClipboard()). Or if you prefer export image of Metafile I recommend that use next code that works correctly here with last version of TeeChart.Net.

Code: Select all

  TChart1.Legend.CustomPosition = True
        TChart1.Legend.Transparency = 100
        TChart1.Legend.Font.Color = Color.Transparent
        TChart1.Export.Image.Metafile.EMFFormat = System.Drawing.Imaging.EmfType.EmfPlusOnly
        TChart1.Export.Image.Metafile.Save("c:\\teeChart1.emf")
Using previous code I have got next image in .emf format:
teeChart1.zip
(3.29 KiB) Downloaded 856 times
Please, could you tell us if previous code solve your problem?

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

Uli
Newbie
Newbie
Posts: 80
Joined: Thu Apr 22, 2010 12:00 am

Re: Changed behavior in legend

Post by Uli » Wed Jun 23, 2010 3:09 pm

Hi Sandra,

sorry, I overlooked the code sample suggested by Christopher:
With

Code: Select all

tChart1.Legend.Items.Custom = true
the items top and left properties are now OK, my custom items were drawn. Thanks!

With respect to the other issue ("regular item text" visible after copying to clipboard): I tried it out now. Unfortunately, Christophers suggestion

Code: Select all

        TChart1.Export.Image.PNG.CopyToClipboard()

leads only to an empty chart (no data series) in Word or Paint.

With your proposal

Code: Select all

        TChart1.Legend.Transparency = 100
        TChart1.Legend.Font.Color = Color.Transparent
        TChart1.Export.Image.Metafile.EMFFormat = System.Drawing.Imaging.EmfType.EmfPlusOnly
        ActChildForm.Chart1.Export.Image.Metafile.CopyToClipboard()

I still get the white "regular items" text by copy to/paste from clipboard.

The alternative to import the chart into other applications by first saving the file is highly uncomfortable and fuzzy. Are there further possibilities?

Best regards

Uli

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

Re: Changed behavior in legend

Post by Sandra » Fri Jun 25, 2010 8:42 am

Hello Uli,
I still get the white "regular items" text by copy to/paste from clipboard.
Ok, I have added it in Bug list with number [TF02015005] and we try to fix it for next maintenance releases of TeeChart.Net.
The alternative to import the chart into other applications by first saving the file is highly uncomfortable and fuzzy. Are there further possibilities?
Could you please explain us exactly what are you doing? Because we can try to find other solution for help you.

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

Uli
Newbie
Newbie
Posts: 80
Joined: Thu Apr 22, 2010 12:00 am

Re: Changed behavior in legend

Post by Uli » Fri Jun 25, 2010 9:27 am

Hi Sandra,
Could you please explain us exactly what are you doing? Because we can try to find other solution for help you.
I don't know what you need as "exact" explanation, the details are all in the previous postings. I will try to summarize again:

I need to draw rich text in the legend items. In order to get sub- and superscripts I go the following way:
- creating custom rich text for legend items. This is a RichTextBox.RTF string.
- setting the "regular" legend font to color.transparent but the same size as in my "custom" rich text. (must be invisible)
- drawing the "custom" legend items (the RichTextBox.RTF) in a function called from within the TChart.AfterDraw event using "regular" items
properties
- the "regular" items text properties hold the unformated text of the rich text (in order to use the "regular" legend with, height, ...,
properties)
More details you may find in the previous messages.

In the initial message I described two issues:
(1)
With the last release the legend items top and left properties were zero in the TChart.AfterDraw event ([TF02014990]). This problem could be overcome by the code suggested by Christopher.
(2)
I need to export the chart as image into Word and other applications. The export as metafile results in images where the "regular" items text becomes visible (though the legend font was set to color.transparent) as white "ghost" text below the "custom" rich text. You and Christopher suggested some code to overcome this but it does not work. The possibility to save the chart as a file and then to import this file into the other applications is not an acceptable alternative.


Regards

Uli

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

Re: Changed behavior in legend

Post by Sandra » Fri Jun 25, 2010 10:50 am

Hello Uli,

Sorry if I explained too well. I wanted to refer concretely to the export of image that is your last explanation.
With respect to the other issue ("regular item text" visible after copying to clipboard): I tried it out now. Unfortunately, Christophers suggestion

TChart1.Export.Image.PNG.CopyToClipboard()

leads only to an empty chart (no data series) in Word or Paint.
I try again code that suggest Christopher and here seems that works fine with last version of TeeChart.Net and using next code:

Code: Select all

  private Steema.TeeChart.Styles.Line lineser, lineser2;
        private void InitializeChart()
        {
            lineser = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            lineser.FillSampleValues();
            lineser2 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            lineser2.FillSampleValues();
     
        }

        private void button1_Click(object sender, EventArgs e)
        {
            tChart1.Legend.CustomPosition = true;
            tChart1.Legend.Color = Color.Transparent;
            tChart1.Legend.Font.Color = Color.Transparent;
            tChart1.Graphics3D.BufferStyle = Steema.TeeChart.Drawing.BufferStyle.OptimizedBuffer;
            tChart1.Export.Image.PNG.CopyToClipboard();
        }
I get next image .png with chart full:
tChart1.PNG
tChart1.PNG (16.23 KiB) Viewed 23269 times
Do you get a same as snippet image above?

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

Uli
Newbie
Newbie
Posts: 80
Joined: Thu Apr 22, 2010 12:00 am

Re: Changed behavior in legend

Post by Uli » Fri Jun 25, 2010 12:05 pm

Hi Sandra,

I tried the code of Christopher with a minimal sample application again. Now it works. I just realized that the first attempt I carried out with my current code under work and I forgot to comment out a following line which copied another empty chart... Sorry! Obviously I was a little bit confused since I tried some other things, too.

I assume this as a workaround with which I can live up to the next maintenance release. But you are still asked to make possible a correct metafile copy via clipboard since the png copy looks not so good when changing the size.

Best regards

Uli

Uli
Newbie
Newbie
Posts: 80
Joined: Thu Apr 22, 2010 12:00 am

Re: Changed behavior in legend

Post by Uli » Fri Jun 25, 2010 1:16 pm

Supplement to last posting

Hi Sandra,

in his message Christopher suggested

Code: Select all

tChart1.Legend.Items.Custom = true;
to be able to get the legend items top and left values and

Code: Select all

tChart1.Export.Image.PNG.CopyToClipboard();
to solve the problem with the "ghost" text. So I checked both for the individual problems to solve (and did it wrong with respect to the png export).

After submitting the last message I went back to my actual code to implement the png clipboard export. And asked me the question whether the

Code: Select all

tChart1.Legend.Items.Custom = true;
may eventually have an influence on the metafile file export, too. And it has: The metafile export seems now to work correctly!

Have a nice weekend

Uli

Uli
Newbie
Newbie
Posts: 80
Joined: Thu Apr 22, 2010 12:00 am

Re: Changed behavior in legend

Post by Uli » Thu Jul 15, 2010 9:36 am

Hi Sandra,

after my euphoria in the last message that Christopers workaround solves the problem with metafile (it was my first impression) some deeper testing was done. In summary, this has shown that with bug number [TF02014990] sufficient work with the legend is not more possible. I again wasted a lot of hours to come to this conclusion.

So I have to ask you: Can you provide an assembly where this bug is fixed? Of course, I would be glad if the other bugs which make my work with TeeChart so extremly frustrating would be fixed in this assembly, too.

Best regards

Uli

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

Re: Changed behavior in legend

Post by Narcís » Thu Jul 22, 2010 11:10 am

Hi Uli,

Sorry for the delayed reply. Please see Marc's answers here.

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

Post Reply