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

ScatterLineSeries

1 Answer 90 Views
Chart
This is a migrated thread and some comments may be shown as answers.
James DAmour
Top achievements
Rank 1
James DAmour asked on 28 Feb 2012, 01:02 AM
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

1 Answer, 1 is accepted

Sort by
0
Accepted
Evgenia
Telerik team
answered on 28 Feb 2012, 01:55 PM
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 >>
Tags
Chart
Asked by
James DAmour
Top achievements
Rank 1
Answers by
Evgenia
Telerik team
Share this question
or