We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How to display Pie Chart legend?

Thread ID:

Created:

Updated:

Platform:

Replies:

104500 Jul 24,2012 04:25 PM Jul 30,2014 08:28 AM Silverlight 4
loading
Tags: Chart
Pierre-Alain GALTIER
Asked On July 24, 2012 04:25 PM

Hello,

I don't know why but I can't make a simple pie chart sample with a legend work.

I created a new business application projet and update the Home class constructor (in Home.xaml.cs file) as follow:

            InitializeComponent();

            this.Title = ApplicationStrings.HomePageTitle;

            Chart myChart = new Chart();         
            ChartArea area = new ChartArea();
            ChartSeries series = new ChartSeries();
            ChartAdornmentInfo adornment = new ChartAdornmentInfo();
            ChartLegend legend = new ChartLegend();           
                                 
            legend.DockPosition = ChartDock.Top;           

            series.Type = ChartTypes.Pie;
            series.Label = "Series1";
            series.IsIndexed = false;
            ChartPieType.SetExplodedIndex(series,1);
            series.DataSource = new ObservableCollection<NamedValue>() {new NamedValue("Part 1", 40), new NamedValue("Part 2", 60)};
            series.BindingPathX = "Name";
            series.BindingPathsY = new List<string>() {"Value"};
           
            // Initialize the Adornment Information.
            adornment.Visible = true;
            adornment.HorizontalAlignment = HorizontalAlignment.Center;
            adornment.VerticalAlignment = VerticalAlignment.Top;           
            adornment.SegmentLabelContent = LabelContent.Percentage;
            adornment.SegmentLabelFontFamily = new FontFamily("Segoe UI");
           
            series.AdornmentsInfo = adornment;

            area.Legends = legend;           
            area.Series.Add(series);
            myChart.Areas.Add(area);

            ContentStackPanel.Children.Add(myChart);


and I added the following class

public class NamedValue
    {
        public string Name{get;set;}       
        public double Value{get;set;}

        public NamedValue(string name, double value)
        {
            Name = name;
            Value = value;

        }
    }

I don't know why but I have no legend in my chart.

Any Idea ?

Thank you

Rajkumar [Syncfusion]
Replied On July 26, 2012 01:32 AM

Hi PierreAlainGaltier,
 
Thanks for your interest in Syncfusion products.
 
We are unable to reproduce the issue and the added code is sufficient enough to display Legends. Please try to set the visibility of Legends as in below code snippet and check whether the legend is visible or not.
Code Snippet:
legend.Visibility = System.Windows.Visibility.Visible;
If you are still having a problem in displaying Legends, please create a direct track incident regarding this issue. So that we can analyze more on this and provide a better solution.
 
Thanks,
Rajkumar B R

Scott Harner
Replied On July 29, 2014 09:09 PM

I realize this is an old thread, but I am trying to get a legend to show with a pie chart using version 10.2.0.75 and am also having no luck. I took the original poster's code and pasted it into a brand new windows phone 7.1 project. The chart shows, but the legend does not. I tried this on one box using vs 2010 express on windows vista and another box using vs 2012 express on windows 8. I notice that there is also no legend when I run the sample browser project that was provided despite the fact that there is legend xaml included with the pie chart.

Suresh S [Syncfusion]
Replied On July 30, 2014 06:48 AM

Hi Scott,

We have introduced the new SfChart control  for Windows Phone from 11.1 version. Could you please upgrade to the latest version?

Regards,
Suresh S

Scott Harner
Replied On July 30, 2014 08:28 AM

It's good to hear that the issue has been addressed in a newer version. I had won a copy of Essential Studio at a user group meeting a while back, but didn't have a reason to use it during my year of support. I finally had a personal project where it made sense to give Essential Studio a try, by adding a pie chart, but unfortunately it is not working in the newest version that I had access to (10.2.0.75). Regardless, thanks for the quick follow-up response.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;