Bind Collection to Chart (BarSeries)

7 posts, 0 answers
  1. Nino
    Nino avatar
    19 posts
    Member since:
    Apr 2012

    Posted 13 Nov 2013 Link to this post

    Hi



    I'm trying to Bind my data to my Bar Serie. But my chart is empty.


    My Objects:

    public class Statistic : INotifyPropertyChanged
    {
        public List<DataPoint> Data;
     
        public List<DataPoint> Required;
     
        public List<DataPoint> Average;
    }


    public class DataPoint
    {
        public double DataValue { get; set; }
     
        public DateTime Category { get; set; }
    }


    My Statistic Site:

    public AreaStatistik()
    {
        InitializeComponent();
     
        App.ViewModel.LoadStatistic(StartDate, EndDate, Typ);
        DataContext = App.ViewModel.StatisticData;
    }


    Xaml


    <telerikChart:RadCartesianChart Name="Chart" >
        <telerikChart:RadCartesianChart.Behaviors>
            <telerikChart:ChartPanAndZoomBehavior ZoomMode="Horizontal" PanMode="Horizontal"/>
        </telerikChart:RadCartesianChart.Behaviors>
     
        <telerikChart:RadCartesianChart.VerticalAxis>
            <telerikChart:LinearAxis />
        </telerikChart:RadCartesianChart.VerticalAxis>
     
        <telerikChart:RadCartesianChart.HorizontalAxis >
            <telerikChart:DateTimeCategoricalAxis LabelFitMode="Rotate" LabelFormat="dd.MM.yyy" DateTimeComponent="Date"/>
        </telerikChart:RadCartesianChart.HorizontalAxis>
     
        <telerikChart:BarSeries Name="DataSerie" ItemsSource="{Binding Data}" CombineMode="Stack" >
            <telerikChart:BarSeries.ValueBinding>
                <telerikChart:PropertyNameDataPointBinding PropertyName="DataValue" />
            </telerikChart:BarSeries.ValueBinding>
            <telerikChart:BarSeries.CategoryBinding>
                <telerikChart:PropertyNameDataPointBinding PropertyName="Category"/>
            </telerikChart:BarSeries.CategoryBinding>
        </telerikChart:BarSeries>
    </telerikChart:RadCartesianChart>




    Anyone a idea what's wrong?



    Thanks

    Nino

  2. Ivo
    Admin
    Ivo avatar
    90 posts

    Posted 18 Nov 2013 Link to this post

    Hi,
    According to the provided code snippets, everything seems to be OK.
    Could you, please send us the whole project in order to debug what is the reason for not showing any data at the chart?

    Regards,
    Ivo
    Telerik
    Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
  3. DevCraft banner
  4. Elisha
    Elisha avatar
    2 posts
    Member since:
    Nov 2013

    Posted 23 Nov 2013 Link to this post

    <telerikChart:RadCartesianChart HorizontalAlignment="Left"
                                    Name="test"
                                    VerticalAlignment="Top" />
    anytime i place a radcartesianchart i get the following error. 
    FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.Shell.11.0, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
    stack trace:
    at Telerik.Windows.Controls.Design.GaugeGalleryContainer..ctor(Control galleryUI)
       at Telerik.Windows.Controls.Design.DesignTimegalleryAdornerProvider.Activate(ModelItem item) in c:\Builds\204\WindowsPhone\BuildAll\Sources\Design\Gallery\DesignTimeGalleryAdornerProvider.cs:line 41
       at Microsoft.Windows.Design.Interaction.AdornerProvider.InvokeActivate(EditingContext context, ModelItem item)
       at MS.Internal.Features.AdornerProviderFeatureConnector.FeatureProvidersAdded(ModelItem item, IEnumerable`1 extensions)
       at Microsoft.Windows.Design.Policies.PolicyDrivenFeatureConnector`1.OnPolicyItemsChanged(Object sender, PolicyItemsChangedEventArgs e)
       at Microsoft.Windows.Design.Policies.ItemPolicy.OnPolicyItemsChanged(PolicyItemsChangedEventArgs e)
       at Microsoft.Windows.Design.Policies.SelectionPolicy.OnSelectionChanged(Selection newSelection)
       at Microsoft.Windows.Design.ContextItemManager.SubscribeProxy`1.SubscribeContext(ContextItem item)
       at Microsoft.Windows.Design.SubscribeContextCallback.Invoke(ContextItem item)
       at Microsoft.Windows.Design.EditingContext.DefaultContextItemManager.OnItemChanged(ContextItem item)
       at Microsoft.Windows.Design.EditingContext.DefaultContextItemManager.SetValue(ContextItem value)
       at Microsoft.Expression.DesignSurface.ViewModel.Extensibility.ExtensibilityManager.SetSelection(Selection selection)
       at Microsoft.Expression.DesignSurface.ViewModel.Extensibility.ExtensibilityManager.OnViewModelEarlySceneUpdatePhase(Object sender, SceneUpdatePhaseEventArgs args)
       at Microsoft.Expression.DesignSurface.ViewModel.SceneUpdatePhaseEventHandler.Invoke(Object sender, SceneUpdatePhaseEventArgs e)
       at Microsoft.Expression.DesignSurface.ViewModel.SceneViewModel.FireEarlySceneUpdatePhase(SceneUpdatePhaseEventArgs args)
       at Microsoft.Expression.DesignSurface.View.SceneViewUpdateScheduleTask.UpdateEarly()
       at Microsoft.Expression.Utility.Scheduler.ScheduleTask.Update()
       at Microsoft.Expression.Utility.Scheduler.SchedulingService.DispatchTasksAtPriority(DispatcherPriority priority)
       at Microsoft.Expression.Utility.Scheduler.SchedulingService.DispatcherToken.Dispatch(Object arg)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
    what can be the problem?
  5. Ivo
    Admin
    Ivo avatar
    90 posts

    Posted 25 Nov 2013 Link to this post

    Hi Elisha,
    That is a  known issues and has been already fixed.
    Could you, please try to reproduce it with the latest internal build, where the fix is included? There should not be any more errors in the VS2013 designer when creating charts.

    Regards,
    Ivo
    Telerik
    Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
  6. Elisha
    Elisha avatar
    2 posts
    Member since:
    Nov 2013

    Posted 25 Nov 2013 Link to this post

    Thank you. I have just updated the profile and now its working well. keep up with the good work. your success is our success... :-)
  7. Nino
    Nino avatar
    19 posts
    Member since:
    Apr 2012

    Posted 18 Dec 2013 Link to this post

    I tried it again in a other project. With the following code it works in the expected way:

    <telerikChart:RadCartesianChart Name="Chart">
        <telerikChart:RadCartesianChart.Behaviors>
            <telerikChart:ChartPanAndZoomBehavior ZoomMode="Horizontal" PanMode="Horizontal"/>
        </telerikChart:RadCartesianChart.Behaviors>
     
        <telerikChart:RadCartesianChart.VerticalAxis>
            <telerikChart:LinearAxis />
        </telerikChart:RadCartesianChart.VerticalAxis>
     
        <telerikChart:RadCartesianChart.HorizontalAxis >
            <telerikChart:DateTimeCategoricalAxis LabelFitMode="Rotate" LabelFormat="dd.MM.yyy" DateTimeComponent="Date"/>
        </telerikChart:RadCartesianChart.HorizontalAxis>
     
        <telerikChart:RadCartesianChart.Series>
            <telerikChart:BarSeries Name="DataSerie" CombineMode="Stack" ItemsSource="{Binding StatisticIntakes, Mode=TwoWay}" >
                <telerikChart:BarSeries.ValueBinding>
                    <telerikChart:PropertyNameDataPointBinding PropertyName="Amount" />
                </telerikChart:BarSeries.ValueBinding>
                <telerikChart:BarSeries.CategoryBinding>
                    <telerikChart:PropertyNameDataPointBinding PropertyName="Date"/>
                </telerikChart:BarSeries.CategoryBinding>
            </telerikChart:BarSeries>
        </telerikChart:RadCartesianChart.Series>
    </telerikChart:RadCartesianChart>

    Code Behind:

    if (App.StatisticViewModel.StatisticIntakes == null)
    {
        App.StatisticViewModel.LoadStatisticData(null, null);
    }
     
    DataContext = App.StatisticViewModel;


    StatisticIntakes is here just a normale CodeFirst Database Table.

    I guess my fault was that I hadn't this line in my first try:

    <telerikChart:RadCartesianChart.Series>

    so there wheren't a collection to add the serie.

    Regards
    Nino
     
  8. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 19 Dec 2013 Link to this post

    Hi Nino,

    It's great that you managed to find a solution.
    Write again if you need assistance with something else.

    Regards,
    Victor
    Telerik
    Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
Back to Top
DevCraft banner