Using OtherSlice gives incorrect data

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
girusgroup
Newbie
Newbie
Posts: 3
Joined: Fri Oct 27, 2006 12:00 am
Contact:

Using OtherSlice gives incorrect data

Post by girusgroup » Mon Aug 02, 2010 11:25 am

Hi

I'm using Teechart V2 (build 2.0.2489.20951) in an aspx application in Visual Studio 2005.

I am creating a Chart as below ....

Dim objPie As New Steema.TeeChart.Styles.Pie
objPie.OtherSlice.Style = Steema.TeeChart.Styles.PieOtherStyles.BelowPercent
objPie.OtherSlice.Value = 15
objPie.OtherSlice.Text = "Other"
TChart.Chart.Series.Add(objPie)

TChart.Chart.Legend.Visible = False
TChart.Chart.Series(0).Marks.Visible = True
TChart.Chart.Series(0).Marks.Style = Steema.TeeChart.Styles.MarksStyles.LabelPercent

TChart.Chart.Series(0).Add(CDbl(32), "Slice1", System.Drawing.Color.Red)
TChart.Chart.Series(0).Add(CDbl(30), "Slice2", System.Drawing.Color.Blue)
TChart.Chart.Series(0).Add(CDbl(25), "Slice3", System.Drawing.Color.Green)
TChart.Chart.Series(0).Add(CDbl(5), "Slice4", System.Drawing.Color.Yellow)
TChart.Chart.Series(0).Add(CDbl(8), "Slice5", System.Drawing.Color.Cyan)


Now you will see that the data values I have provided here add up to 100, so that each slice should have a percentage of the whole pie which is equal to the data value, ie Sloice 1 will occupy 32% of the pie. This works fine when all the values are shown seperately - without using the "OtherSlice" feature.
However, when I use the OtherSlice feature as in the above code, with the OtherSlice.Value set to 15, Slice4 and Slice5 become combined as the "Other" Slice but my pie chart then shows the following values for the slices ...

Slice 1 = 36.78%
Slice2 = 34.48%
Slice3 = 28.74%
Other = 14.94%

This gives a total pie of 114.98% which is obviously wrong!

You will see that the three ungrouped Slices 1 to 3 actually add up to the 100% (rounding errors accepted)

What is going on here?

Regards
Mike

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

Re: Using OtherSlice gives incorrect data

Post by Sandra » Wed Aug 04, 2010 9:56 am

Hello Mike,

Sorry for delay. I have informed that I could reproduce your problem using last version 2 of TeeChart .Net, but not in current version of TeeChart .Net (version 4) because in it works correctly.
Moreover, I have found a workaround that you can use for solve your problem:

Code: Select all

 protected void Page_Load(object sender, EventArgs e)
    {
        InitializeChart();

    }
    Steema.TeeChart.Styles.Pie objPie;
    private void InitializeChart()
    {
        objPie = new Steema.TeeChart.Styles.Pie(WebChart1.Chart);
       WebChart1.Chart.Aspect.View3D = false;
       objPie.OtherSlice.Style = Steema.TeeChart.Styles.PieOtherStyles.BelowPercent;
        objPie.OtherSlice.Value = 15;
        objPie.OtherSlice.Text = "Other";
        WebChart1.Chart.Legend.Visible = false;
        objPie.Marks.Visible = true;
        objPie.Marks.Style = Steema.TeeChart.Styles.MarksStyles.Label;
        objPie.Add(32,"Slice1",System.Drawing.Color.Red);
        objPie.Add(30,"Slice2",System.Drawing.Color.Blue);
        objPie.Add(25,"Slice3",System.Drawing.Color.Green);
        objPie.Add(5,"Slice5",System.Drawing.Color.Yellow);
        objPie.Add(8,"Slice6",System.Drawing.Color.Cyan);
        objPie.GetSeriesMark += new Steema.TeeChart.Styles.Series.GetSeriesMarkEventHandler(objPie_GetSeriesMark);
    }
    void objPie_GetSeriesMark(Steema.TeeChart.Styles.Series series, Steema.TeeChart.Styles.GetSeriesMarkEventArgs e)
    {
    double value = objPie.YValues.Total;
    e.MarkText = e.MarkText+" "+(series.YValues[e.ValueIndex] * value / 100).ToString()+ "%"; 
    } 
Could you please, 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

Post Reply