Binding to collection of series

May 28, 2013 at 5:55 AM
Hi!

Thanks for your great work, it's really easy to use.

I'm just having a problem when I want to bind to a collection of series instead to just one series. I found the SeriesCollection but dont know how to use it.

Is there a syntax like

<chart:SeriesCollection SeriesSource="{Binding MyListOfSeries}"></chart:SeriesCollection>

or something similar?

Thank you in advance
Michael R.
Coordinator
May 28, 2013 at 7:31 AM
Hi Micheal,

Thanks for supporting sparrow toolkit.

You can bind the series collection like as below

//In C# MyListOfSeries should be the type of SeriesCollection
public SeriesCollection MyListOfSeries { get; set; }

//In XAML
<chart:SparrowChart Series="{Binding MyListOfSeries}"/>

Note:Please take an update from Nuget. This issue is fixed from the version 13.1.0.105

Please let me know if you have any queries

Regards,
Vinoth Kumar J
May 28, 2013 at 11:01 AM
Edited May 28, 2013 at 11:21 AM
Hello Vinoth,

thanks, this works fine and helped me for the described issue.

However I get an exception now during the GUI initalization with the version 13.1.0.106 just by adding following lines to the code:
        <chart:SparrowChart Grid.Row="1" Margin="10">
            <chart:SparrowChart.YAxis>
                <chart:LinearYAxis Header="Strom"></chart:LinearYAxis>
            </chart:SparrowChart.YAxis>
            <chart:SparrowChart.XAxis>
                <chart:DateTimeXAxis  StringFormat="hh:mm" Interval="0:15:0" MinorTicksCount="0" ShowCrossLines="True" Header="Zeit"  ></chart:DateTimeXAxis>
            </chart:SparrowChart.XAxis>                
            <chart:LineSeries ></chart:LineSeries>
        </chart:SparrowChart>
I didn't get these exception with the toolkit dll I used before (the dll included in de DemoBinaries folder..). If I remove the lines above from the code there is no exception. Here is the exception detail:

System.ArgumentOutOfRangeException wurde nicht behandelt.
HResult=-2146233086
Message=Der Index lag außerhalb des Bereichs. Er muss nicht negativ und kleiner als die Auflistung sein.
Parametername: index
Source=mscorlib
ParamName=index
StackTrace:
   bei System.ThrowHelper.ThrowArgumentOutOfRangeException()
   bei System.Collections.Generic.List`1.get_Item(Int32 index)
   bei System.Collections.ObjectModel.Collection`1.get_Item(Int32 index)
   bei Sparrow.Chart.ContainerCollection.Refresh()
   bei Sparrow.Chart.ContainerCollection.ContainerCollection_SizeChanged(Object sender, SizeChangedEventArgs e)
   bei System.Windows.SizeChangedEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   bei System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   bei System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   bei System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   bei System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   bei System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
   bei System.Windows.FrameworkElement.OnRenderSizeChanged(SizeChangedInfo sizeInfo)
   bei System.Windows.ContextLayoutManager.fireSizeChangedEvents()
   bei System.Windows.ContextLayoutManager.UpdateLayout()
   bei System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
   bei System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
   bei System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
   bei System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
   bei System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
   bei System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   bei MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
   bei System.Windows.Threading.DispatcherOperation.InvokeImpl()
   bei System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
   bei System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   bei System.Windows.Threading.DispatcherOperation.Invoke()
   bei System.Windows.Threading.Dispatcher.ProcessQueue()
   bei System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   bei MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   bei MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   bei System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   bei MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
   bei System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   bei MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   bei System.Windows.Forms.Application.Run(ApplicationContext context)
   bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
   bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
   bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
   bei TAv3.My.MyApplication.Main(String[] Args)


  • edit: The same error occures when i add the 13.1.0.106 version to the sparrow.chart.demos project
Coordinator
May 28, 2013 at 11:35 AM
Hi Micheal,

Sorry for the inconvenience caused.

Now I have fixed this issue and published the build in Nuget.
Please take an update in Nuget.

Regards,
Vinoth Kumar J
May 28, 2013 at 1:02 PM
Hi Vinoth,

Thank you for your quick responses and fixes.

The recently reportet error seems to be fixed, however i get an error during startup randomly. Sometimes it works, sometimes not. Seems to be a threading issue.

Thanks
Michael

System.ArgumentNullException wurde nicht behandelt.
HResult=-2147467261
Message=Der Wert darf nicht NULL sein.
Parametername: Untergeordnete Elemente von "System.Windows.Controls.UIElementCollection" können nicht Null sein. Es wird ein von "UIElement" abgeleitetes Objekt erwartet.
Source=PresentationFramework
ParamName=Untergeordnete Elemente von "System.Windows.Controls.UIElementCollection" können nicht Null sein. Es wird ein von "UIElement" abgeleitetes Objekt erwartet.
StackTrace:
   bei System.Windows.Controls.UIElementCollection.ValidateElement(UIElement element)
   bei System.Windows.Controls.UIElementCollection.AddInternal(UIElement element)
   bei System.Windows.Controls.UIElementCollection.Add(UIElement element)
   bei Sparrow.Chart.LineContainer.DrawPath(SeriesBase series, Pen pen)
   bei Sparrow.Chart.SeriesContainer.Draw()
   bei Sparrow.Chart.SeriesContainer.<Invalidate>b__3()
   bei System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   bei MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
   bei System.Windows.Threading.DispatcherOperation.InvokeImpl()
   bei System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
   bei System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   bei System.Windows.Threading.DispatcherOperation.Invoke()
   bei System.Windows.Threading.Dispatcher.ProcessQueue()
   bei System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   bei MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   bei MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   bei System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   bei MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
   bei System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   bei MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   bei System.Windows.Forms.Application.Run(ApplicationContext context)
   bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
   bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
   bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
   bei TAv3.My.MyApplication.Main(String[] Args)
InnerException:
Coordinator
May 28, 2013 at 3:17 PM
Hi Micheal,

Sorry for the continuous Exceptions,

I have fixed and committed the above mentioned issue. Due to some build problems, i didn't published the build.
Meanwhile could you please provide me the reproducing steps or a simple sample for above issue which is helpful for me to serve you better.

Thanks,
Vinoth Kumar J
Coordinator
May 28, 2013 at 4:46 PM
Hi Micheal,

I had published the build in Nuget. Please take an update and check whether above issue has been fixed.

Thanks,
Vinoth Kumar J
May 29, 2013 at 8:14 AM
Hi Vinoth,

with the last release you published everything seems to work fine so far! I'll let you know if I come across more errors.

Many Thanks,
Michael
Jun 7, 2013 at 7:26 PM
Hi!
Congratulation for the toolkit!

I want to bind a collection of LineSeries. Is it possible?
Where i can find a simple example?

Thanks!
Coordinator
Jun 11, 2013 at 6:42 AM
Edited Jun 11, 2013 at 6:52 AM
HI,

Sorry for the delayed response.

The below code shows the simple way to bind a collection of LineSeries to SparrowChart
//In C#
public ObservableCollection<Model> Collection { get; set; }
public ObservableCollection<Model> Collection1 { get; set; }
public SeriesCollection LineSeries { get; set; } 

public MainPage()
 {
            Collection = new ObservableCollection<Model>();
            Collection1 = new ObservableCollection<Model>();
            Random r=new Random();
            for (int i = 0; i < 10; i++)
            {
                Collection.Add(new Model(i, r.Next(0, 10)));
                Collection1.Add(new Model(i, r.Next(0, 10)));
            }
           LineSeries Series1 = newLineSeries();
            Series1.PointsSource = this.Collection;
            Series1.XPath = "XData";
            Series1.YPath = "YValue";
            this.LineSeries.Add(Series1);
            Series1 = new LineSeries();
            Series1.PointsSource = this.Collection1;
            Series1.XPath = "XData";
            Series1.YPath = "YValue";
            this.LineSeries.Add(Series1);
            this.DataContext = this;
}

//Model Class
public class Model
{
        public double XData { get; set; }
        public double YValue { get; set; }
        public Model(double xData,double yValue)
        {
            this.XData = xData;
            this.YValue = yValue;
        }
}   
In XAML bind the LineSeries collection to Series property of SparrowChart.
          <sparrow:SparrowChart Series="{Binding LineSeries}">
                <sparrow:SparrowChart.XAxis>
                    <sparrow:LinearXAxis/>
                </sparrow:SparrowChart.XAxis>
                <sparrow:SparrowChart.YAxis>
                    <sparrow:LinearYAxis/>
                </sparrow:SparrowChart.YAxis>
            </sparrow:SparrowChart>
Please let me know if you need more information

Thanks & Regards,
Vinoth Kumar J
Jun 13, 2013 at 9:16 AM
Hello Vinoth,

with the actual Version of NUget I get the same error written by caveman5 at May 28 at 3:02 PM

Regards
Michael
Coordinator
Jun 13, 2013 at 5:29 PM
Hi Micheal,

I could not able to reproduce the issue in the current version. Can you please tell me the version from which the designer issue is reproducing.

Regards,
Vinoth Kumar J
Jun 14, 2013 at 6:57 AM
Hi Vinoth,

I get the error during runtime. After the constructor ist finished with this.datacontext = this and leaving the function.
The version of sparrow.chart.wpf.40 = 13.1.0.111

Many thanks
Michael
Jun 15, 2013 at 1:24 PM
Hi!
Thanks for your reply!
I tried your code but unfortunately the xaml designer gives me an error.
Image

Then, I tried to change the code but the chart is empty..
//xaml
<sparrow:SparrowChart x:Name="chart">
                <sparrow:SparrowChart.XAxis>
                    <sparrow:LinearXAxis/>
                </sparrow:SparrowChart.XAxis>
                <sparrow:SparrowChart.YAxis>
                    <sparrow:LinearYAxis/>
                </sparrow:SparrowChart.YAxis>
</sparrow:SparrowChart>

//c#
public partial class MainPage : PhoneApplicationPage
    {

        public MainPage()
        {
            InitializeComponent();
            chart.Series = load();
        }

        private SeriesCollection load()
        {
            ObservableCollection<Model> Collection;
            ObservableCollection<Model> Collection1;
            SeriesCollection LineSeries;

            LineSeries = new SeriesCollection();
            Collection = new ObservableCollection<Model>();
            Collection1 = new ObservableCollection<Model>();
            Random r = new Random();
            for (int i = 0; i < 10; i++)
            {
                Collection.Add(new Model(i, r.Next(0, 10)));
                Collection1.Add(new Model(i, r.Next(0, 10)));
            }
            LineSeries Series1 = new LineSeries();
            Series1.PointsSource = Collection;
            Series1.XPath = "XData";
            Series1.YPath = "YValue";
            LineSeries.Add(Series1);
            Series1 = new LineSeries();
            Series1.PointsSource = Collection1;
            Series1.XPath = "XData";
            Series1.YPath = "YValue";
            LineSeries.Add(Series1);
            return LineSeries;
        }

        //Model Class
        public class Model
        {
            public double XData { get; set; }
            public double YValue { get; set; }
            public Model(double xData, double yValue)
            {
                this.XData = xData;
                this.YValue = yValue;
            }
        }
    }
Thanks
Coordinator
Jun 18, 2013 at 4:43 PM
Hi,

Please take an update in Nuget.

Thanks,
Vinoth Kumar J
Jun 19, 2013 at 9:39 AM
vinothsparrow wrote:
Hi,

Please take an update in Nuget.

Thanks,
Vinoth Kumar J
Hi,
i have updated the toolkit Sparrow.Chart.WP8.45 13.1.0.113, but I have the same issues,
Image
and the SeriesCollection is not bind with the chart.

Thanks
Coordinator
Jun 20, 2013 at 7:11 AM
Hi,

Please change the code the as like in the below code snippet.
      private SeriesCollection load()
        {
            ObservableCollection<Model> Collection;
            ObservableCollection<Model> Collection1;
            SeriesCollection LineSeries;

            LineSeries = new SeriesCollection();
            Collection = new ObservableCollection<Model>();
            Collection1 = new ObservableCollection<Model>();
            Random r = new Random();
            for (int i = 0; i < 10; i++)
            {
                Collection.Add(new Model(i, r.Next(0, 10)));
                Collection1.Add(new Model(i, r.Next(0, 10)));
            }
            LineSeries Series1 = new LineSeries();
            Series1.XPath = "XData";
            Series1.YPath = "YValue";
            Series1.PointsSource = Collection;
         
            LineSeries.Add(Series1);
            Series1 = new LineSeries();
            Series1.XPath = "XData";
            Series1.YPath = "YValue";
            Series1.PointsSource = Collection1;
           
            LineSeries.Add(Series1);
            return LineSeries;
        }
I have just moved the Series1.XPath = "XData"; and Series1.YPath = "YValue"; line above the Series1.PointsSource = Collection; is set.

Please let me know if you need more information on this.

Thanks,
Vinoth Kumar J
Jun 29, 2013 at 8:13 AM
HI,
sorry for the delayed response.
Now the code works great!
Thank you for your support.
Oct 16, 2013 at 2:40 PM
Hi Vinoth !

Thank you for this great component. Really great work.

Can I ask you about one problem.
I'm using WPG for Windiws 8 and Dot net framework 4.5

My Problem is similiar to the post above.

I'm developing a solution with "Binding to collection of series" as you disccused it above.
I have a problem in following situation.
If I put your call "chart.Series = load();" from ctor in a method behind a simple button, then in that case I don't get nothing.
My Chart is empty. I don't get any error, but content is also not there.
What part of Charts initialization I'm missing (some events are not thrown, i believe)

Can you help me.
thanks

zeljko
Dec 13, 2013 at 1:45 AM
Edited Dec 13, 2013 at 1:45 AM
zak777 wrote:
Hi Vinoth !

Thank you for this great component. Really great work.

Can I ask you about one problem.
I'm using WPG for Windiws 8 and Dot net framework 4.5

My Problem is similiar to the post above.

I'm developing a solution with "Binding to collection of series" as you disccused it above.
I have a problem in following situation.
If I put your call "chart.Series = load();" from ctor in a method behind a simple button, then in that case I don't get nothing.
My Chart is empty. I don't get any error, but content is also not there.
What part of Charts initialization I'm missing (some events are not thrown, i believe)

Can you help me.
thanks

zeljko
I had the same issue. you can fix this with:

chart.Series = load();
chart.OnApplyTemplate();
Feb 9, 2014 at 11:20 AM
Hi.

I have some problems with binding to Series property of SparrowChart. I'm using <package id="Sparrow.Chart.WP8" version="13.1.0.113" targetFramework="wp80" />

Everything works great, when collection in my ViewModel creates before Series property binds to it.
i.e.
public SeriesCollection Series { get { return series ?? (series = CreateSeries()); } }
public SeriesCollection CreateSeries()
{
 //Creating series
}
I want to implement another scenario. SeriesCollection should be empty on binding. When page activates(or button clicks), data loads and series creates. Number of series depends on data.
i.e.
public SeriesCollection Series { get { return series ?? (series =new SeriesCollection()); } }
//Executes after the binding complete
public void LoadData()
{
   Series.Clear();
   var s1 = new LineSeries()...
   //...
  Series.Add(s1);  
}
After method LoadData executes SparrowChart updates axis, but doesn't draw series.
Project to show bug https://skydrive.live.com/redir?resid=D22346A1E4AB3307!6571&authkey=!ABV1_gYB_QzUM9o&ithint=file%2c.zip

After a little research I find out that Sparrow.Chart.ContainerCollection.GenerateConatiners doesn't executes after SeriesCollection changed, but executes Sparrow.Chart.ContainerCollection.UpdateContainers, but collection Sparrow.Chart.ContainerCollection.Containers is empty.

I tried to run GenerateConatiners evry time when collection changed and this solved my problem, but I want updated nuget package with normal bug fix.

Thanks
Feb 27, 2014 at 12:37 PM
Edited Feb 27, 2014 at 12:48 PM
LineSeries = new SeriesCollection();
"The type 'System.Windows.Forms.DataVisualization.Charting.SeriesCollection' has no constructors defined."

Edit:

<BANGS HEAD ON DESK>
I added the wrong namespace: I was "Using System....Charting.DataVisualization" rather than "Using Sparrow.Chart"
Jan 26, 2016 at 1:38 AM
I think this project is exactly what I need. My graph will need to change the Y axis between linear and logarithmic and the x axis should remain as linear. The number of series that I need to draw will vary between 3 and 12. Because of this, I'll need to use a dynamic series binding instead of a static number of line series. I've gotten the WPF example working from the documentation. But I can't get the examples above to work. The chart comes up as a blank chart X/Y Axis 0-1 range. I'm using Visual Studio 2013 with a basic WPF project and .Net 4.5.1. Was the issue that ihtfw brought up fixed?


Here is my code:

Program:
using System;
using System.Windows;

namespace TestSparrowChart
{
public partial class MainWindow : Window
{
    TestViewModel context = new TestViewModel();
    public MainWindow()
    {
        InitializeComponent();
        this.DataContext = context;
    }
}
}



View Model:
using System;
using Sparrow.Chart;
using System.Collections.ObjectModel;

namespace TestSparrowChart
{
public class TestViewModel : ViewModelBase
{
    public System.Collections.ObjectModel.ObservableCollection<Model> Collection { get; set; }
    public Sparrow.Chart.SeriesCollection LineSeries { get; set; }

    public TestViewModel()
    {
        load();
    }

    private Sparrow.Chart.SeriesCollection load()
    {
        LineSeries = new Sparrow.Chart.SeriesCollection();
        Collection = new ObservableCollection<Model>();
        System.Random r = new System.Random();
        for (int i = 0; i < 10; i++)
        {
            Collection.Add(new Model(i, r.Next(0, 10)));
        }
        Sparrow.Chart.LineSeries Series1 = new Sparrow.Chart.LineSeries();
        Series1.PointsSource = Collection;
        Series1.XPath = "X";
        Series1.YPath = "Y";
        LineSeries.Add(Series1);
        RaisePropertyChangedEvent("LineSeries");
        return LineSeries;
    }

}

public class Model
{
    public double X { get; set; }
    public double Y { get; set; }
    public Model(double x,double y)
    {
        this.X = x;
        this.Y = y;
    }
}
}

XAML:
<Window x:Class="TestSparrowChart.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sparrow="http://sparrowtoolkit.codeplex.com/wpf"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    mc:Ignorable="d" 
    d:DesignHeight="300" 
    d:DesignWidth="300">
<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <sparrow:SparrowChart x:Name="chart" Series="{Binding LineSeries}">
        <sparrow:SparrowChart.XAxis>
            <sparrow:LinearXAxis/>
        </sparrow:SparrowChart.XAxis>
        <sparrow:SparrowChart.YAxis>
            <sparrow:LinearYAxis/>
        </sparrow:SparrowChart.YAxis>
    </sparrow:SparrowChart>
</Grid>
</Window>
Mar 31, 2016 at 11:46 AM
vinothsparrow wrote:
Hi,

Please change the code the as like in the below code snippet.
      private SeriesCollection load()
        {
            ObservableCollection<Model> Collection;
            ObservableCollection<Model> Collection1;
            SeriesCollection LineSeries;

            LineSeries = new SeriesCollection();
            Collection = new ObservableCollection<Model>();
            Collection1 = new ObservableCollection<Model>();
            Random r = new Random();
            for (int i = 0; i < 10; i++)
            {
                Collection.Add(new Model(i, r.Next(0, 10)));
                Collection1.Add(new Model(i, r.Next(0, 10)));
            }
            LineSeries Series1 = new LineSeries();
            Series1.XPath = "XData";
            Series1.YPath = "YValue";
            Series1.PointsSource = Collection;
         
            LineSeries.Add(Series1);
            Series1 = new LineSeries();
            Series1.XPath = "XData";
            Series1.YPath = "YValue";
            Series1.PointsSource = Collection1;
           
            LineSeries.Add(Series1);
            return LineSeries;
        }
I have just moved the Series1.XPath = "XData"; and Series1.YPath = "YValue"; line above the Series1.PointsSource = Collection; is set.

Please let me know if you need more information on this.

Thanks,
Vinoth Kumar J
Hi Vinoth,

I am applying this code in WPF with MVVM pattern.
The chart is empty.

Do you have an idea on how I should do?

Cheers