Hi
I'm populating a radChart using a WCF service call that returns two fields: fiscal_year (int) and bd_rev_annual (money). If I load the chart simply by setting the ItemsSource to the result of method GetBudgetsByYearAsync() (not calling procedure ConfigureBudgetChart) then the chart displays as expected. However, if I call procedure ConfigureBudgetChart before assigning the ItemsSource the data in the chart is duplicated (two bars instead of one for each fiscal year) and the datapointMember X values still display as (0,1,2) rather than (2008, 2009, 2010) as I would expect...
Also you'll note in the xaml code at the end that the radChart tag displays as <my:RadChart> rather than <telerikChart:RadChart> as would be expected...I have made the correct references so am not sure why this is happening...
This is the first time I've tried anything with Silverlight so am not too sure what's going on - any help would be greatly appreciated
Thanks,
Brian
--------------------------------------------------------------------
Imports System
Imports System.Collections.Generic
Imports Microsoft.VisualBasic
Imports System.Linq
Imports System.Net
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Documents
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Animation
Imports System.Windows.Shapes
Imports Telerik.Windows.Controls.Charting
Imports freebalanceSilverlight.FreebalanceSvc
Partial Public Class MainPage
Inherits UserControl
Public Sub New()
InitializeComponent()
AddHandler Loaded, AddressOf MainPage_Loaded
End Sub
Private Sub MainPage_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
Dim proxy As FreebalanceSvc.FreebalanceServiceClient = New FreebalanceSvc.FreebalanceServiceClient
AddHandler proxy.GetBudgetsByYearCompleted, AddressOf proxy_GetBudgetByYearCompleted
proxy.GetBudgetsByYearAsync()
End Sub
Private Sub proxy_GetBudgetByYearCompleted(ByVal sender As Object, ByVal e As FreebalanceSvc.GetBudgetsByYearCompletedEventArgs)
ConfigureBudgetChart()
Me.chart1.ItemsSource = e.Result
End Sub
Private Sub ConfigureBudgetChart()
Me.chart1.DefaultView.ChartArea.AxisX.Title = "Fiscal Years"
Me.chart1.DefaultView.ChartArea.AxisY.Title = "Dollars"
Dim seriesMapping As New SeriesMapping()
seriesMapping.LegendLabel = "Budget"
seriesMapping.SeriesDefinition = New BarSeriesDefinition
seriesMapping.ItemMappings.Add(New ItemMapping("fiscal_year", DataPointMember.XValue))
seriesMapping.ItemMappings.Add(New ItemMapping("bd_rev_annual", DataPointMember.YValue))
chart1.SeriesMappings.Add(seriesMapping)
End Sub
End Class
--------------------------------------------------------------------
--------------------------------------------------------------------
<UserControl xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" xmlns:telerikInput="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input" xmlns:my="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Charting" x:Class="freebalanceSilverlight.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
<Grid x:Name="LayoutRoot" Background="White">
<my:RadChart x:Name="chart1">
</my:RadChart>
<telerikNavigation:RadCoverFlow></telerikNavigation:RadCoverFlow>
<telerikInput:RadComboBox></telerikInput:RadComboBox>
</Grid>
</UserControl>
--------------------------------------------------------------------