This is a migrated thread and some comments may be shown as answers.

Bind Collection to Chart (BarSeries)

6 Answers 112 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Nino
Top achievements
Rank 1
Nino asked on 13 Nov 2013, 09:13 PM

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

6 Answers, 1 is accepted

Sort by
0
Ivo
Telerik team
answered on 18 Nov 2013, 12:32 PM
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.
0
Elisha
Top achievements
Rank 2
answered on 23 Nov 2013, 04:56 PM
<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?
0
Ivo
Telerik team
answered on 25 Nov 2013, 07:55 AM
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.
0
Elisha
Top achievements
Rank 2
answered on 26 Nov 2013, 04:55 AM
Thank you. I have just updated the profile and now its working well. keep up with the good work. your success is our success... :-)
0
Nino
Top achievements
Rank 1
answered on 18 Dec 2013, 03:04 PM
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
 
0
Victor
Telerik team
answered on 19 Dec 2013, 08:03 AM
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.
Tags
Chart
Asked by
Nino
Top achievements
Rank 1
Answers by
Ivo
Telerik team
Elisha
Top achievements
Rank 2
Nino
Top achievements
Rank 1
Victor
Telerik team
Share this question
or