Displaying Symbols On Legend

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
lilo
Newbie
Newbie
Posts: 14
Joined: Fri Sep 07, 2012 12:00 am

Displaying Symbols On Legend

Post by lilo » Thu Jan 17, 2013 8:16 am

I am having trouble displaying chart symbols in the chart legend of of one of my apps. The symbols (pointer styles) will not display in the legend, although the colors are correct.

Legend Code

Points1.Chart.Legend.Alignment = Steema.TeeChart.LegendAlignments.Right
Points1.Chart.Legend.Transparent = False
Points1.Chart.Legend.Transparency = 0
Points1.Chart.Legend.Height = 200
Points1.Chart.Legend.Width = 130
Points1.Chart.Legend.AutoSize = False
Points1.Chart.Legend.ResizeChart = False
Points1.Chart.Legend.Visible = True
Points1.Chart.Legend.Title.Font.Name = "Arial"
Points1.Chart.Legend.Title.Font.Size = 12
Points1.Chart.Legend.Title.Text = "Legend"
Points1.Chart.Legend.Title.Visible = True
LegendScrollBar1.DrawStyle = Steema.TeeChart.Tools.ScrollBarDrawStyle.WhenNeeded
Points1.Chart.Legend.CustomPosition = False
Points1.Chart.Legend.TopLeftPos = 1

I use GetPointerStyle to set the chart symbols

Sub Points1_GetPointerStyle(ByVal series As Object, ByVal e As Steema.TeeChart.Styles.GetPointerStyleEventArgs)
If Symbol2(e.ValueIndex) = 33 Then e.Style = Steema.TeeChart.Styles.PointerStyles.Rectangle
If Symbol2(e.ValueIndex) = 34 Then e.Style = Steema.TeeChart.Styles.PointerStyles.Circle
If Symbol2(e.ValueIndex) = 35 Then e.Style = Steema.TeeChart.Styles.PointerStyles.Triangle
If Symbol2(e.ValueIndex) = 36 Then e.Style = Steema.TeeChart.Styles.PointerStyles.DownTriangle
If Symbol2(e.ValueIndex) = 37 Then e.Style = Steema.TeeChart.Styles.PointerStyles.Cross
If Symbol2(e.ValueIndex) = 38 Then e.Style = Steema.TeeChart.Styles.PointerStyles.DiagCross
If Symbol2(e.ValueIndex) = 39 Then e.Style = Steema.TeeChart.Styles.PointerStyles.Star
If Symbol2(e.ValueIndex) = 40 Then e.Style = Steema.TeeChart.Styles.PointerStyles.Diamond
If Symbol2(e.ValueIndex) = 41 Then e.Style = Steema.TeeChart.Styles.PointerStyles.LeftTriangle
If Symbol2(e.ValueIndex) = 42 Then e.Style = Steema.TeeChart.Styles.PointerStyles.RightTriangle
If Symbol2(e.ValueIndex) = 43 Then e.Style = Steema.TeeChart.Styles.PointerStyles.Hexagon
If Symbol2(e.ValueIndex) = 44 Then e.Style = Steema.TeeChart.Styles.PointerStyles.Nothing
Exit Sub
Error1:
Exit Sub
End Sub
Chart1Test.jpg
Chart1Test.jpg (44.88 KiB) Viewed 8535 times

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

Re: Displaying Symbols On Legend

Post by Sandra » Thu Jan 17, 2013 3:36 pm

Hello lilo,


Ok. Next code works for me using last version of TeeChartFor.Net:

Code: Select all

public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }
        Steema.TeeChart.Styles.Points Points1;
        Steema.TeeChart.Tools.LegendScrollBar LegendScrollBar1;
        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;
            Points1 = new Points(tChart1.Chart);
            LegendScrollBar1 = new Steema.TeeChart.Tools.LegendScrollBar(tChart1.Chart);
            Points1.Chart.Legend.Alignment = Steema.TeeChart.LegendAlignments.Right;
            Points1.Chart.Legend.Transparent = false;
            Points1.Chart.Legend.Transparency = 0;
            Points1.Chart.Legend.Height = 200;
            Points1.Chart.Legend.Width = 130;
           
           Points1.Chart.Legend.Title.Font.Name = "Arial";
           Points1.Chart.Legend.Title.Font.Size = 12;
           Points1.Chart.Legend.Title.Text = "Legend";
           Points1.Chart.Legend.Title.Visible = true;
           LegendScrollBar1.DrawStyle = Steema.TeeChart.Tools.ScrollBarDrawStyle.WhenNeeded;
           Points1.Chart.Legend.CustomPosition = false;
           Points1.Chart.Legend.TopLeftPos = 1;
            Random rnd = new Random();
            for (int i = 33; i < 45; i++)
            {
                Points1.Add(i, rnd.Next(100));
            }
            Points1.GetPointerStyle += new CustomPoint.GetPointerStyleEventHandler(Points1_GetPointerStyle);
        }

        void Points1_GetPointerStyle(CustomPoint series, GetPointerStyleEventArgs e)
        {
            
            if (series[e.ValueIndex].X== 33) 
            {
                e.Style = Steema.TeeChart.Styles.PointerStyles.Rectangle;
                e.Color = Color.Red;
            }
            if (series[e.ValueIndex].X == 34)
            { 
                e.Style = Steema.TeeChart.Styles.PointerStyles.Circle;
                e.Color = Color.Orange;
            }
            if (series[e.ValueIndex].X == 35) 
            { 
                e.Style = Steema.TeeChart.Styles.PointerStyles.Triangle;
                e.Color = Color.Green;
            }
            if (series[e.ValueIndex].X == 36)
            {
                e.Style = Steema.TeeChart.Styles.PointerStyles.DownTriangle;
                e.Color = Color.Yellow;
            }
            if (series[e.ValueIndex].X == 37) 
            { 
                e.Style = Steema.TeeChart.Styles.PointerStyles.Cross;
                e.Color = Color.Purple;
            }
            if (series[e.ValueIndex].X == 38) 
            { 
                e.Style = Steema.TeeChart.Styles.PointerStyles.DiagCross;
                e.Color = Color.AliceBlue;
            }
            if (series[e.ValueIndex].X == 39) 
            {
                e.Style = Steema.TeeChart.Styles.PointerStyles.Star;
                e.Color = Color.Black;
            }
            if (series[e.ValueIndex].X == 40)
            { 
                e.Style = Steema.TeeChart.Styles.PointerStyles.Diamond;
                e.Color = Color.Chocolate;
            }
            if (series[e.ValueIndex].X == 41) 
            { 
                e.Style = Steema.TeeChart.Styles.PointerStyles.LeftTriangle;
                e.Color = Color.Fuchsia; 
            }
            if (series[e.ValueIndex].X == 42) 
            { 
                e.Style = Steema.TeeChart.Styles.PointerStyles.RightTriangle;
                e.Color = Color.Gold;
            }
            if (series[e.ValueIndex].X == 43)
            { 
                e.Style = Steema.TeeChart.Styles.PointerStyles.Hexagon;
                e.Color = Color.Aquamarine;
            }
            if (series[e.ValueIndex].X == 44) 
            { 
                e.Style = Steema.TeeChart.Styles.PointerStyles.Nothing;
                e.Color = Color.LemonChiffon;
            
            }

        }
Could you please tell us if previous code works in your end?

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

lilo
Newbie
Newbie
Posts: 14
Joined: Fri Sep 07, 2012 12:00 am

Re: Displaying Symbols On Legend

Post by lilo » Fri Jan 18, 2013 2:15 pm

Sorry, this did not work for me.

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

Re: Displaying Symbols On Legend

Post by Sandra » Fri Jan 18, 2013 2:30 pm

Hello lilo,

Ok. Could you tell us which version are you using? On the other hand, as my code doesn't work for you, could you explain what is the exactly problem, because we can try to help you, because the code I suggest you, works for me correctly. If you prefer, you can send your project, so, we can review your code.

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

lilo
Newbie
Newbie
Posts: 14
Joined: Fri Sep 07, 2012 12:00 am

Re: Displaying Symbols On Legend

Post by lilo » Sun Jan 20, 2013 11:02 am

I am using the latest version. If I use the code in a new (different) application, it works fine. There is some problem with the configuration of the existing application to stop the Legend from working properly. Everything else in the Tchart works fine. Any ideas, apart from deleting the Tchart and starting from the beginning?

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

Re: Displaying Symbols On Legend

Post by Sandra » Mon Jan 21, 2013 12:06 pm

Hello lilo,

There is some options to try to solve your problem before remove the TChart or change the application. I recommend you do next:

One options is:
  • 1.- Close application.
    2.- Go to the folder path application.
    3.- Remove folder bin and obj
    4.- Reopen the project.
    5.- Rebuild again the project and run it.
The other option, is Clear solution Explorer:
  • 1.- select the project solution.
    2.- Right mouse button and select clear.
    3.- Rebuild the project.
    4.- Run the project to check the problem persist.

More things you must check:
  • - TChart is in correct version.
    -Compilation use all projects.
    -...
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

Post Reply