Private Sub DataCharts() Dim dt As DataTable = GetData("Chart_Monthly1") Dim departments As List(Of String) = (From p In dt.AsEnumerable() Select p.Field(Of String)("Department")).Distinct().ToList() If Chart1.Series.Count() = 1 Then Chart1.Series.Remove(Chart1.Series(0)) End If _Chart1.Series.Clear() For Each department As String In departments Dim x As String() = (From p In dt.AsEnumerable() Where p.Field(Of String)("Department") = department Order By p.Field(Of String)("year") Select p.Field(Of String)("year")).ToArray Dim y As Decimal() = (From p In dt.AsEnumerable() Where p.Field(Of String)("Department") = department Order By p.Field(Of String)("year") Select p.Field(Of Decimal)("Total")).ToArray() Chart1.Series.Add(New Series(department)) Chart1.Series(department).IsValueShownAsLabel = True Chart1.Series(department).BorderWidth = 2 Chart1.Series(department).ChartType = SeriesChartType.Spline Chart1.Series(department).Points.DataBindXY(x, y) Chart1.Series(department).LabelForeColor = Color.MediumSeaGreen Next Chart1.Legends(0).Enabled = True End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)