Pie Charts percentages rounded

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
THoMaSiN
Newbie
Newbie
Posts: 36
Joined: Mon Apr 14, 2008 12:00 am

Pie Charts percentages rounded

Post by THoMaSiN » Fri Apr 17, 2009 5:35 pm

Hello,

Is there any way that using the marks style as percent in a pie series, the percentages DO NOT SHOW decimal numbers (round to the nearest integer)?

Currently I'm using :

Code: Select all

 cs.Marks.Style = TeeChart.Styles.MarksStyles.Percent
Thanks.

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

Post by Sandra » Mon Apr 20, 2009 8:50 am

Hello THoMaSiN,

If you want the percentage do not show decimal number, you need change type of marks using GetSeriesMark event. I do a simple code that you could use:

Inizialitze Chart:

Code: Select all

        private void InitializeChart()
        {
            Steema.TeeChart.Styles.Bar bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
            bar1.FillSampleValues();
            bar1.Marks.Style = Steema.TeeChart.Styles.MarksStyles.Percent;
            bar1.GetSeriesMark += new Steema.TeeChart.Styles.Series.GetSeriesMarkEventHandler(bar1_GetSeriesMark);       
        }
GetSeriesMark Event:

Code: Select all

        void bar1_GetSeriesMark(Steema.TeeChart.Styles.Series series, Steema.TeeChart.Styles.GetSeriesMarkEventArgs e)
        {
            e.MarkText = e.MarkText.Replace("%", "");
            double tmp = Convert.ToDouble(e.MarkText);
            e.MarkText = Convert.ToString(Math.Round(tmp)) + " %";

        }
Please, check that if this code works fine.

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