Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
275
I want XamPieChart labels in Percentages
posted

Hi,

I am working on C# using Visual Studio 2010 with Infragistics 11.2.

I want to replace the previous XamChart of the type 'Pie' with the new  XamPieChart which is available in 11.2.

What I need is to convert the labels of the slices to percentages, Although there was no built in feature in previous versions as well but I had found a work around for this from this post  http://forums.infragistics.com/forums/p/59904/306721.aspx#306721

and what in fact I was doing is

 private void XamChart1_ChartRendered(object sender,   Infragistics.Windows.Chart.ChartRenderedEventArgs e)

        {
//suppose sum is 1000.

                double sum = 1000;
                foreach (var item in this.XamChart1.Series[0].DataPoints)
                {
                    Marker marker = new Marker();
                    if (sum != 0)
                    {
                        double percent = Math.Round((((item.Value) / sum) * 100), 2);
                        marker.Format = percent.ToString() + "%";
                    }

                    item.Marker = marker;
                }
            }

 

now how can I replace the XamPieChart labels with percentages, because it is different from the XamChart.

I will be very thankful for any kind of help

thanks and regards

Any.

  • 138253
    Offline posted

    Hello,

     

    Thank you for your post. I have been looking into it and I created a sample project for you with the functionality you want. Basically I added a property of a custom class type which has a Double Property with the same value as the XamPieChart’s Values and I overridden my class ToString method so that I can have a formatted Label. Please let me know if this helps you or you need further assistance on this matter.

     

    Looking forward for your reply.

    XamPieChartLabelFormat.zip
  • 138253
    Offline posted

    Hello Any,

     

    I am just checking if you got this worked out or you still require any assistance or clarification on the matter.