SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components
Please note! These examples are new to SciChart Mobile v3 release! SciChart iOS & Android ship with Xamarin.iOS and Xamarin.Android bindings around our native iOS & Android Chart controls, allowing you to create fast & feature rich charts to your Xamarin applications. We include ~90 native iOS examples and 90 Android examples, but now also ~60 Xamarin Chart Examples to help you get started with SciChart. You can download the source for our Xamarin Chart Examples from Github, or browse the source code below.
Line chart is one of the most commonly used charts on all platforms across many industries. This example demonstrates how to create a Xamarin Line Chart in code. SciChart Xamarin Line Chart supports millions of points out of the box*, and is suitable for use in real-time scientific, medical and trading applications.
*depending on available memory and device.
Documentation on how to use this type in iOS here: The iOS Line Chart Documentation.
Documentation on how to use this type Android here: The Android Line Chart Documentation.
See also how to add series in Xamarin from our tutorials for Xamarin iOS and Xamarin Android.
Tip!
You can be very flexible and change the Line appearance as follows:
The C#/Xamarin.iOS/Xamarin.Android source code for the Xamarin Line Chart example is included below (Scroll down!).
Did you know you can also view the source code from one of the following sources as well?
using Android.Views.Animations;
using SciChart.Charting.Model;
using SciChart.Charting.Model.DataSeries;
using SciChart.Charting.Modifiers;
using SciChart.Charting.Visuals;
using SciChart.Charting.Visuals.Animations;
using SciChart.Charting.Visuals.Axes;
using SciChart.Charting.Visuals.RenderableSeries;
using SciChart.Data.Model;
using SciChart.Drawing.Common;
using Xamarin.Examples.Demo.Data;
using Xamarin.Examples.Demo;
using Xamarin.Examples.Demo.Droid.Extensions;
using Xamarin.Examples.Demo.Droid.Fragments.Base;
namespace Xamarin.Examples.Demo.Droid.Fragments.Examples
{
[ExampleDefinition("Line Chart", description:"Create a simple Line Chart", icon: ExampleIcon.LineChart)]
public class LineChartFragment : ExampleBaseFragment
{
public SciChartSurface Surface => View.FindViewById<SciChartSurface>(Resource.Id.chart);
public override int ExampleLayoutId => Resource.Layout.Example_Single_Chart_Fragment;
protected override void InitExample()
{
var xAxis = new NumericAxis(Activity) {GrowBy = new DoubleRange(0.1, 0.1), VisibleRange = new DoubleRange(1.1, 2.7)};
var yAxis = new NumericAxis(Activity) {GrowBy = new DoubleRange(0.1, 0.1)};
var fourierSeries = DataManager.Instance.GetFourierSeries(1.0, 0.1);
var dataSeries = new XyDataSeries<double, double>();
dataSeries.Append(fourierSeries.XData, fourierSeries.YData);
var rSeries = new FastLineRenderableSeries {DataSeries = dataSeries, StrokeStyle = new SolidPenStyle(0xFF279B27, 2f.ToDip(Activity))};
using (Surface.SuspendUpdates())
{
Surface.XAxes.Add(xAxis);
Surface.YAxes.Add(yAxis);
Surface.RenderableSeries.Add(rSeries);
Surface.ChartModifiers = new ChartModifierCollection
{
new ZoomPanModifier(),
new PinchZoomModifier(),
new ZoomExtentsModifier(),
};
new SweepAnimatorBuilder(rSeries) { Interpolator = new DecelerateInterpolator(), Duration = 3000, StartDelay = 350 }.Start();
}
}
}
}