This is a migrated thread and some comments may be shown as answers.

MVVM - Legend Label Binding

3 Answers 117 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Icarus
Top achievements
Rank 1
Icarus asked on 21 Jan 2011, 11:51 AM

Hi, 

I am working with MVVM on a Telerik piechart

I have a Dictionnary<string, int> which I would like to represent with a piechart. The value could easily be represented on the piechart but the problem is the keys of the dictionnary are not considered as legend labels. How can I fix this problem?

<telerik:RadChart Margin="15,15,15,15" Grid.Row="0" Grid.Column="1"  HorizontalAlignment="Center" Background="Transparent" BorderThickness="0" FontSize="10" ItemsSource="{Binding Path=RightTopCollection}" >
    <telerik:RadChart.DefaultSeriesDefinition>
        <telerik:PieSeriesDefinition >
            <telerik:PieSeriesDefinition.InteractivitySettings >
                <telerik:InteractivitySettings HoverScope="Item" SelectionScope="Item" SelectionMode="Single" />
            </telerik:PieSeriesDefinition.InteractivitySettings>
        </telerik:PieSeriesDefinition>
    </telerik:RadChart.DefaultSeriesDefinition>
</telerik:RadChart>

// In constructor
 this._RightTopCollection = new Dictionary<string, int>() {{"firstLabel", 4}, {"secondLabel", 25}, {"thirdLabel", 17}, {"fourthLabel", 19}, {" fifthLabel", 7} };
  
  
// Class declaration
  #region RightTopCollection
        public const string RightTopCollectionPropertyName = "RightTopCollection";
        private Dictionary<string, int> _RightTopCollection = null;
        public Dictionary<string, int> RightTopCollection
        {
            get
            {
                return _RightTopCollection;
            }
  
            set
            {
                if (_RightTopCollection == value)
                {
                    return;
                }
  
                var oldValue = _RightTopCollection;
                _RightTopCollection = value;
  
                // Update bindings, no broadcast
                RaisePropertyChanged(RightTopCollectionPropertyName);
            }
        }
        #endregion

3 Answers, 1 is accepted

Sort by
0
Evgenia
Telerik team
answered on 27 Jan 2011, 09:00 AM
Hi Icarus,

Please review our demo which uses the MVVM pattern and will help you to get the idea of controlling the Legend Labels.
I hope this gets you started properly.

Regards,
Evgenia
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Accepted
Evgenia
Telerik team
answered on 27 Jan 2011, 12:17 PM
Hello Icarus,

You can find a sample project attached demostrating a Pie chart databound using Manual Series Mappings.

Best wishes,
Evgenia
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Icarus
Top achievements
Rank 1
answered on 28 Jan 2011, 10:33 AM
It was exactly what I do need . Thank you.
Tags
Chart
Asked by
Icarus
Top achievements
Rank 1
Answers by
Evgenia
Telerik team
Icarus
Top achievements
Rank 1
Share this question
or