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

how to plot multiple scatter spline lines in scatter splot in telerik:RadCartesianChart?

4 Answers 124 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
steven
Top achievements
Rank 1
steven asked on 15 Mar 2017, 03:03 PM

There is a comment in  Example.xaml file which clearly summarizes what I am trying to.

This file is included in the attach zip file.

Iam having trouble finding and easy way to plot multiple scatter spline lines in a scattor plot.

I am using version 4.5  telerick controls , and specifically the telerik:RadCartesianChart

I gutted out the galley scatter example code in the terlerik examples wpf source project into a simple WPF project.

The project in the example uses telerik:LinearAxis which requires a dependency objext and a half million other things that is needed in this project.

The WPF project just retrieves the data from the same csv file and stores the data in the two same list in the corresponding viewmodel.

public class ExampleViewModel : DataSourceViewModelBase

{

 private IEnumerable<HourlyEarnings> _privateData;
        private IEnumerable<HourlyEarnings> _publicData;

 

How can simply just databind these two lists in the view model to the chart in the xaml to produce to scatter spline lines in the chart.

I have a attached the project.

I spent days searching the web for a simple example and everything i found either requires some serviceprovider object that seem not to be for wpf apps, or just information that is worthless or code that does not compile or shown one line.

4 Answers, 1 is accepted

Sort by
0
steven
Top achievements
Rank 1
answered on 15 Mar 2017, 03:08 PM

I forgot to attach the source code.

I had to change to zip extension to png  to post the sour code.

Change the extension to zip after downloading .

The source code project was developed in visual studio 2015

0
steven
Top achievements
Rank 1
answered on 15 Mar 2017, 03:12 PM

you can email me direct at stevensrf@mail.com with any suggestion.

And below is the Example.xaml code with the comment .

<UserControl x:Class="ScatterWpfApp.ScatterPoint.Example"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:ScatterWpfApp.ScatterPoint"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.DataContext>
        <local:ExampleViewModel />
    </UserControl.DataContext>
    <Grid>
        <telerik:RadCartesianChart>
            <!--What do I put in here to data bind IEnumerable<HourlyEarnings> PrivateData and
             IEnumerable<HourlyEarnings> PublicData iin the ExampleViewModel class to produce
            to scatter spline lines in a scatter chart-->
        </telerik:RadCartesianChart>       
    </Grid>
</UserControl>

0
steven
Top achievements
Rank 1
answered on 15 Mar 2017, 03:44 PM

And yes I tired binding per enumerable list as show below that there a some exception wierd ass thrown in the telerik control at runtime

 

       <telerik:RadCartesianChart Name="RadCartesianChart">
            <!--What do I put in here to data bind IEnumerable<HourlyEarnings> PrivateData and
             IEnumerable<HourlyEarnings> PublicData iin the ExampleViewModel class to produce
            to scatter spline lines in a scatter chart-->
            <telerik:RadCartesianChart.VerticalAxis>
                <telerik:LinearAxis/>
            </telerik:RadCartesianChart.VerticalAxis>
            <telerik:RadCartesianChart.HorizontalAxis>
                <telerik:LinearAxis/>
            </telerik:RadCartesianChart.HorizontalAxis>

            <!--This does not work. Why who knows. Binding like this at compile time throws some weird ass exception-->
            <telerik:ScatterSplineSeries ItemsSource="{Binding PublicData}" XValueBinding="XYal" YValueBinding="YVal">
                
            </telerik:ScatterSplineSeries>
            <telerik:ScatterSplineSeries ItemsSource="{Binding PrivateData}" XValueBinding="XYal" YValueBinding="YVal">

            </telerik:ScatterSplineSeries>
        </telerik:RadCartesianChart>  

0
steven
Top achievements
Rank 1
answered on 15 Mar 2017, 03:47 PM

But this binding works

     <telerik:RadCartesianChart Name="RadCartesianChart">
            <!--What do I put in here to data bind IEnumerable<HourlyEarnings> PrivateData and
             IEnumerable<HourlyEarnings> PublicData iin the ExampleViewModel class to produce
            to scatter spline lines in a scatter chart-->
            <telerik:RadCartesianChart.VerticalAxis>
                <telerik:LinearAxis/>
            </telerik:RadCartesianChart.VerticalAxis>
            <telerik:RadCartesianChart.HorizontalAxis>
                <telerik:LinearAxis/>
            </telerik:RadCartesianChart.HorizontalAxis>
            <telerik:ScatterSplineSeries ItemsSource="{Binding PublicData}" XValueBinding="Age" YValueBinding="Wage">
                
            </telerik:ScatterSplineSeries>
            <telerik:ScatterSplineSeries ItemsSource="{Binding PrivateData}" XValueBinding="Age" YValueBinding="Wage">

            </telerik:ScatterSplineSeries>
        </telerik:RadCartesianChart>    

Tags
General Discussions
Asked by
steven
Top achievements
Rank 1
Answers by
steven
Top achievements
Rank 1
Share this question
or