This question is locked. New answers and comments are not allowed.
Below is code to add four identical charts to a wrappanel.
What code should be added to the function 'CreateCommodityCharts' to:
1. Change the charts to Pie charts.
2. Add Legends for the Companies.
Thank you.
-----------------------------------------------------------------------
Namespace Views
Public Class CommodityChartViewModel
Private _data As IEnumerable(Of Company)
Private _wrappanel As WrapPanel
Public ReadOnly Property ChartWrapPanel As WrapPanel
Get
If Me._wrappanel Is Nothing Then
Me._wrappanel = CreateCommodityCharts
End If
Return Me._wrappanel
End Get
End Property
Private Function CreateCommodityCharts() As WrapPanel
' Instantiate a new WrapPanel and set properties
Dim myWrapPanel As New WrapPanel()
myWrapPanel.Orientation = Orientation.Horizontal
myWrapPanel.Width = 900
myWrapPanel.HorizontalAlignment = Windows.HorizontalAlignment.Left
myWrapPanel.VerticalAlignment = Windows.VerticalAlignment.Top
' Add the Telerik charts to the parent WrapPanel using the Children.Add method.
For cntr = 1 To 4
Dim pc As New Telerik.Windows.Controls.RadChart
pc.Height = 300
pc.Width = 300
pc.ItemsSource = Data
pc.DefaultView.ChartTitle.Content = "RAD Pie Chart " & cntr.ToString
myWrapPanel.Children.Add(pc)
Next
' Add the WrapPanel to the Page as Content
Return myWrapPanel
End Function
Private ReadOnly Property Data() As IEnumerable(Of Company)
Get
If Me._data Is Nothing Then
Me._data = CreateCompanyData()
End If
Return Me._data
End Get
End Property
Function CreateCompanyData() As IEnumerable(Of Company)
Dim companyData As New List(Of Company)(2)
companyData.Add(New Company("Nokia", 90))
companyData.Add(New Company("RIM", 10))
'companyData.Add(New Company("Other", 14))
'companyData.Add(New Company("Apple", 13))
'companyData.Add(New Company("HTC", 6))
'companyData.Add(New Company("Fujitsu", 3))
Return companyData
End Function
Public Class Company
Public Sub New(name As String, share As Double)
Me._name = name
Me._share = share
End Sub
Private _name As String
Private _share As Double
Public Property Name() As String
Get
Return Me._name
End Get
Set(value As String)
If Me._name <> value Then
Me._name = value
End If
End Set
End Property
Public Property Share() As Double
Get
Return Me._share
End Get
Set(value As Double)
If Me._share <> value Then
Me._share = value
End If
End Set
End Property
End Class
End Class
End Namespace