Page 1 of 1

Pie Charts percentages rounded

Posted: Fri Apr 17, 2009 5:35 pm
by 13048857
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.

Posted: Mon Apr 20, 2009 8:50 am
by 10050769
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,