I had this working at one point and now I've messed it up and can't get it working again. I am showing a simple pie chart. The only thing not working is all the legend texts are showing as "DataItem" instead of the values it should. in my case "Assigned", "Rejected", etc.
The data being returned by the recordset:
39 Request in Progress45 Requested2 To be uploaded34 Needs Review15 Rejected
Private Sub ShowInventory() Dim adoRs As DbDataReader 'create pie chart, add to form Dim pieChart As New UltraPieChart() pieChart.Name = "pieChart" UltraPanel1.ClientArea.Controls.Add(pieChart) pieChart.Dock = DockStyle.Left pieChart.Top = 0 pieChart.Left = 0 pieChart.Height = UltraPanel1.Height pieChart.Width = UltraPanel1.Width - 100 'leave room for legend pieChart.OthersCategoryThreshold = 0 pieChart.SelectionMode = SliceSelectionMode.Single pieChart.LabelMemberPath = "Label" pieChart.ValueMemberPath = "Value" pieChart.ShowDefaultTooltip = True adoRs = GetPieChartData() pieChart.DataSource = New PieChartData(adoRs) ''Add legend Dim legend As New UltraItemLegend() legend.Name = "legend" UltraPanel1.ClientArea.Controls.Add(legend) legend.Anchor = AnchorStyles.None legend.Dock = DockStyle.Right pieChart.Legend = legend legend.BringToFront() adoRs = Nothing End Sub Private Function GetPieChartData() As DbDataReader Dim strSQL As String = "SELECT S.StatusDescription as MyLabel,count(*) as MyValue FROM Acct A " _ & "LEFT OUTER JOIN xStatusCodes S ON S.EzaCode=A.Status " GetPieChartData = My.Application.GlobalAuditDB.MExecuteReader(strSQL) End Function
Hello Ted,
Apologies for the late reply.
I am glad to hear that you have resolved your issue.
Thank you for using Infragistics components.
Sincerely,
Tihomir TonevAssociate Software DeveloperInfragistics
Never mind. I fixed it by adding this one line:
pieChart.LegendLabelMemberPath = "Label"
This code might be pertinent as well. I tried changing the following two lines above to match the SQL select, bit then the pie chart doesn't show at all.
pieChart.LabelMemberPath = "MyLabel" pieChart.ValueMemberPath = "MyValue"
Imports System.Collections.ObjectModel Imports System.Data.Common Public Class PieChartData Inherits ObservableCollection(Of DataItem) Public Sub New(ByVal adoRs As DbDataReader) Try If adoRs IsNot Nothing Then Do While adoRs.Read Add(New DataItem() With {.Label = adoRs("MyLabel") & " (" & adoRs("MyValue") & ")", .Value = adoRs("MyValue")}) Loop End If Catch ex As Exception HandledExceptionManager.ShowDialog(gstrWhatHappened, gstrHowUserAffected, gstrWhatUserCanDo, ex, MessageBoxButtons.OK, MessageBoxIcon.Error, HandledExceptionManager.UserErrorDefaultButton.Default) End Try End Sub End Class