Changing Legend Symbol Width in Code?

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Dave
Advanced
Posts: 139
Joined: Mon Sep 22, 2008 12:00 am

Changing Legend Symbol Width in Code?

Post by Dave » Tue Oct 19, 2010 1:06 pm

Hi folks

I can change this setting from the Chart Editor by clicking the Legend tab, then the Symbols tab, then modifying the Width text box

Ive tried doing the following in code:

myChart.Legend.Symbol.Width = 5;
myChart.Legend.Symbol.WidthUnits = Steema.TeeChart.LegendSymbolSize.Pixels;


However the legend symbol width is not changed. Can I do this from code?

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

Re: Changing Legend Symbol Width in Code?

Post by Sandra » Tue Oct 19, 2010 2:32 pm

Hello Dave,

I have made a simple code that increase an decrease width of legend symbols:

Code: Select all

        public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }
        private void InitializeChart()
        {
            Steema.TeeChart.Styles.Bar bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
            bar1.FillSampleValues(5);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            tChart1.Legend.Symbol.WidthUnits = Steema.TeeChart.LegendSymbolSize.Pixels;
            tChart1.Legend.Symbol.Width = tChart1.Legend.Symbol.Width+5;
        }
        private void button2_Click(object sender, EventArgs e)
        {
            tChart1.Legend.Symbol.WidthUnits = Steema.TeeChart.LegendSymbolSize.Pixels;
            tChart1.Legend.Symbol.Width = tChart1.Legend.Symbol.Width - 5;
        }
Could you please, tell us if this code works for you? Moreover, could you say what version of TeeChart.Net are you using?

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

Dave
Advanced
Posts: 139
Joined: Mon Sep 22, 2008 12:00 am

Re: Changing Legend Symbol Width in Code?

Post by Dave » Wed Oct 20, 2010 8:02 am

Sandra

Thanks that works. Ive discovered I need to set the symbol width AFTER adding a series to the chart.

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

Re: Changing Legend Symbol Width in Code?

Post by Sandra » Wed Oct 20, 2010 8:36 am

Hello Dave,

I am glad that solution works for 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

Post Reply