Hi,
How can i create dynamic chart? Right now im declaring the chart in code-behind but it doesn't show at all.
Thanks
How can i create dynamic chart? Right now im declaring the chart in code-behind but it doesn't show at all.
Dim TopSalesItem As XDocument |
Dim ChartTopSellingItems as New RadChart |
Dim format As System.IFormatProvider = New System.Globalization.CultureInfo("en-US") |
Dim ItemsConfig As New List(Of TopSellingOptions) |
Dim intChart As Integer |
Dim intItems As Integer |
Dim series As New DataSeries() |
PanelTopSellingItems.Visibility = Windows.Visibility.Visible |
If intDrillDown = 0 Then |
TopSalesItem = XDocument.Load("XML/Top10SalesItemsByAmount.XML", LoadOptions.SetBaseUri) |
'ChartTopSellingItems.DefaultView.ChartTitle.Content = "Top Selling Items" |
Else |
TopSalesItem = XDocument.Load("XML/Top10SalesItemsByAmount/Top10SalesItemsByAmount" & intLocation & ".XML", LoadOptions.SetBaseUri) |
'ChartTopSellingItems.DefaultView.ChartTitle.Content = "Top Selling Item for " & strLocation |
End If |
ChartTopSellingItems.HorizontalAlignment = Windows.HorizontalAlignment.Stretch |
ChartTopSellingItems.VerticalAlignment = Windows.VerticalAlignment.Stretch |
Select Case ChartTypeTSI.SelectedItem.Content |
Case "Bar" : intChart = 1 |
Case "Horizontal Bar" : intChart = 2 |
Case "Line" : intChart = 3 |
Case "Pie" : intChart = 4 |
Case "Doughnut" : intChart = 5 |
Case "Area" : intChart = 6 |
End Select |
Select Case ItemsTSI.SelectedItem.Content |
Case "Sales" : intItems = 1 |
Case "Sold Items" : intItems = 2 |
End Select |
If datePickerTSI.SelectedDate Is Nothing Then datePickerTSI.SelectedDate = Now.Date |
ItemsConfig.Add(New TopSellingOptions(intChart, intItems, datePickerTSI.SelectedDate)) |
Dim Sales = From SalesElement In TopSalesItem.Descendants("Sales") _ |
Where ConvertDate(SalesElement.Attribute("Date").Value, format) >= ItemsConfig(0).Dates And ConvertDate(SalesElement.Attribute("Date").Value, format) <= ItemsConfig(0).Dates.AddDays(30) |
For i As Integer = 0 To Sales.Count - 1 |
Dim Items = From SalesItem In TopSalesItem.Descendants("Item") _ |
Where ConvertDate(Sales(i).Attribute("Date").Value, format) >= ConvertDate(SalesItem.Element("Date").Value, format) And ConvertDate(Sales(i).Attribute("Date").Value, format) <= ConvertDate(SalesItem.Element("Date").Value, format).AddDays(30) _ |
Select Value = SalesItem.Element("Value").Value, _ |
Name = SalesItem.Element("Name").Value, _ |
Sold = SalesItem.Element("Sold").Value |
Order By Value Ascending |
For x As Integer = 0 To Items.Count - 1 |
Dim point As New DataPoint |
If ItemsConfig(0).Items = 1 Then point.YValue = Items(x).Value 'Sales |
If ItemsConfig(0).Items = 2 Then point.YValue = Items(x).Sold 'Sold |
point.XCategory = Items(x).Name |
series.Add(point) |
Next |
If ItemsConfig(0).Chart = 1 Then series.Definition = New BarSeriesDefinition |
If ItemsConfig(0).Chart = 2 Then series.Definition = New HorizontalBarSeriesDefinition |
If ItemsConfig(0).Chart = 3 Then series.Definition = New LineSeriesDefinition |
If ItemsConfig(0).Chart = 4 Then series.Definition = New PieSeriesDefinition |
If ItemsConfig(0).Chart = 5 Then series.Definition = New DoughnutSeriesDefinition |
If ItemsConfig(0).Chart = 6 Then series.Definition = New AreaSeriesDefinition |
series.Definition.ShowItemLabels = False |
series.Definition.ItemToolTipFormat = "Item: #XCAT" & vbCr & vbLf & "Sales: #Y" |
series.Definition.ShowItemToolTips = True |
ChartTopSellingItems.DefaultView.ChartArea.DataSeries.Clear() |
ChartTopSellingItems.DefaultView.ChartArea.DataSeries.Add(series) |
Next |
Thanks