Quick Start Guide > Tutorials (Xamarin Android) > Xamarin Tutorial 03 - Adding Series to a Chart
Xamarin Tutorial 03 - Adding Series to a Chart
Source code for this tutorial can be found at our SciChart.Android.Examples Github Repository

Adding Series to a SciChartSurface

Following on from Xamarin Tutorial 02 - Creating a SciChartSurface where we created the chart control, added an XAxis and a YAxis, we will now add a some RenderableSeries and some data to the chart.

Declaring a RenderableSeries

To draw a Line and Scatter series on the chart, we need to define two RenderableSeries, and two DataSeries to hold the data. 


First, lets declare the DataSeries

Create DataSeries for the Chart
Copy Code
// Create XyDataSeries to host data for our chart
var lineData = new XyDataSeries<double, double>() {SeriesName = "Sin(x)"};
var scatterData = new XyDataSeries<double, double>() {SeriesName = "Cos(x)"};

For these data series we need to add some data to the chart

Add data for the Chart
Copy Code
// Append data which should be drawn
for (var i = 0; i < 1000; i++)
     lineData.Append(i, Math.Sin(i * 0.1));
     scatterData.Append(i, Math.Cos(i * 0.1));

Then we need to declare the RenderableSeries

Create RenderableSeries for the Chart
Copy Code
// Create line series with data appended into lineData
var lineSeries = new FastLineRenderableSeries()
     DataSeries = lineData,
     StrokeStyle = new SolidPenStyle(Color.LightBlue, 2)

// Create scatter series with data appended into scatterData
var scatterSeries = new XyScatterRenderableSeries()
     DataSeries = scatterData,
     PointMarker = new EllipsePointMarker()
         Width = 10,
         Height = 10,
         StrokeStyle = new SolidPenStyle(Color.Green, 2),
         FillStyle = new SolidBrushStyle(Color.LightBlue)

And finally we need to add them into chart's RenderableSeries collection

Adding RenderableSeries to the Chart
Copy Code
// Add the renderable series to the RenderableSeries collection of the chart

Congratulations! You now have added some series to a chart!

See Also