11-01-21, 06:14 PM
(11-01-21, 07:51 AM)1nj كتب :كود :
Dim query = dt.Rows.Cast(Of DataRow)().GroupBy(Function(x) x.Item("admin").ToString).ToDictionary(Function(x) x.Key, Function(y) y.Count())
Dim labelPoint1 As System.Func(Of ChartPoint, String) = Function(chartPoint) String.Format("{0} ({1:P})", chartPoint.Y, chartPoint.Participation)
Dim seriesCollection1 As New SeriesCollection
For Each item In query
seriesCollection1.Add(New PieSeries With {
.Title = item.Key,
.Values = New ChartValues(Of Integer) From {item.Value},
.PushOut = 15,
.DataLabels = True,
.LabelPoint = labelPoint1
}
)
Next
my_chart.Series = seriesCollection1
الحل ما كنش فعال فقمت بعمل الاتي
عملت كلاس ليأخذ الخصائص
كود :
Public Class classChartData
Private sliceField As Dictionary(Of String, Double) = New Dictionary(Of String, Double)()
Public Property Slice As Dictionary(Of String, Double)
Get
Return sliceField
End Get
Set(ByVal value As Dictionary(Of String, Double))
sliceField = value
End Set
End Property
Public Sub AddSlice(ByVal slicename As String, ByVal slicevalue As Double)
sliceField.Add(slicename, slicevalue)
End Subكود :
Dim query = dt.Rows.Cast(Of DataRow)().GroupBy(Function(x) x.Item("privacy").ToString).Where(Function(g) g.Count > 1).ToDictionary(Function(x) x.Key, Function(y) y.Count())
Dim labelPoint As Func(Of ChartPoint, String) = Function(chartPoint) String.Format("{0} ({1:P})", chartPoint.Y, chartPoint.Participation)
Dim cht_y_values As ChartValues(Of Double) = New ChartValues(Of Double)()
Dim series As LiveCharts.SeriesCollection = New LiveCharts.SeriesCollection()
For Each n In query
my_chart.Series.Add(New PieSeries With {
.Title = n.Key,
.DataLabels = True,
.LabelPoint = labelPoint,
.Values = New ChartValues(Of Double) From {
n.Value
}
})
Next
my_chart.LegendLocation = LegendLocation.Left
