ScatterLineSeries

2 posts, 1 answers
  1. James DAmour
    James DAmour avatar
    7 posts
    Member since:
    Mar 2010

    Posted 27 Feb 2012 Link to this post

    I have been unable to find the backend (C#) code to produce a ScatterLineSeries Chart.

    A small snippet of code would be very helpful.

    Thanks,
    Nelson
  2. Answer
    Evgenia
    Admin
    Evgenia avatar
    1406 posts

    Posted 28 Feb 2012 Link to this post

    Hi James,

    The following source code demonstrates how you can populate a ScatterLine Series with static data in code-behind. Scatter Series are described in more details in our documentation - here for example.

    RadCartesianChart chart = new RadCartesianChart();
               chart.HorizontalAxis = new LinearAxis();
               chart.VerticalAxis = new LinearAxis();
               ScatterLineSeries scatterLine = new ScatterLineSeries();
               scatterLine.Stroke = new SolidColorBrush(Colors.Orange);
               scatterLine.StrokeThickness = 2;
               scatterLine.DataPoints.Add(new ScatterDataPoint() { XValue = 2, YValue = 1 });
               scatterLine.DataPoints.Add(new ScatterDataPoint() { XValue = 5, YValue = 2 });
               scatterLine.DataPoints.Add(new ScatterDataPoint() { XValue = 6 , YValue= 3 });
               scatterLine.DataPoints.Add(new ScatterDataPoint() { XValue = 40, YValue = 4 });
               scatterLine.DataPoints.Add(new ScatterDataPoint() { XValue = 30, YValue = 5 });
               scatterLine.DataPoints.Add(new ScatterDataPoint() { XValue = 50, YValue = 6 });
               Ellipse ellipse = new Ellipse() { Width = 5, Height = 5, Fill = new SolidColorBrush(Colors.Green) };
               scatterLine.PointTemplate = this.Resources["Point"] as DataTemplate;
               chart.Series.Add(scatterLine);
       
               this.LayoutRoot.Children.Add(chart);

    The DataTemplate used is here:

    <UserControl.Resources>
            <DataTemplate x:Key="Point">
      
                <Ellipse Width="8"
                         Height="8"
                         Fill="Green"/>
            </DataTemplate>
        </UserControl.Resources>


    Regards,
    Evgenia
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top