WPF Charting Documentation - SciChart WPF Charts SDK v4.x
Tutorial 02 - Creating a SciChartSurface

The SciChartSurface Type

The root 2D chart control is called the SciChartSurface. This is the WPF Control you will be adding to your applications wherever you need a chart. You can add more than one SciChartSurface, you can configure them independently, and you can link them together.

First up, let’s start by declaring one:

Declaring a SciChartSurface Instance

After Referencing the SciChart DLLs from NuGet (package=SciChart), from local DLL files (referencing DLLs SciChart.Charting, SciChart.Drawing, SciChart.Data, SciChart.Core) or the SciChart Source from Github, a SciChartSurface instance can be declared as follows:


Declaring a SciChartSurface Instance
Copy Code
<Window x:Class="SciChart.Tutorial.MainWindow"
        Title="MainWindow" Height="350" Width="525">
        <!--  Create the chart surface  -->
        <!-- where xmlns:s="http://schemas.abtsoftware.co.uk/scichart" -->
        <s:SciChartSurface x:Name="sciChartSurface">
            <!--  Create an X Axis  -->
                <s:NumericAxis AxisTitle="Number of Samples (per Series)"/>
            <!--  Create a Y Axis  -->
                <s:NumericAxis AxisTitle="Value"/>
            <!--  Specify interactivity modifiers  -->
                    <s:RubberBandXyZoomModifier />
                    <s:ZoomExtentsModifier />
            <!-- Add annotations hints to the user -->
                <s:TextAnnotation Text="Hello world!" X1="5.0" Y1="5.0"/>


Alternative C# code to declare a SciChartSurface is below:

Declaring a SciChartSurface Instance
Copy Code
// Create the chart surface
var sciChartSurface = new SciChartSurface();

// Create the X and Y Axis
var xAxis = new NumericAxis() { AxisTitle = "Number of Samples (per series)"};
var yAxis = new NumericAxis() { AxisTitle = "Value"};

sciChartSurface.XAxis = xAxis;
sciChartSurface.YAxis = yAxis;

// Specify Interactivity Modifiers
sciChartSurface.ChartModifier = new ModifierGroup(new RubberBandXyZoomModifier(), new ZoomExtentsModifier());
// Add annotation hints to the user
var textAnnotation = new TextAnnotation()
   Text = "Hello World!",

The above code declares a SciChartSurface, adds a (numeric) X and Y Axis, adds a single text annotation and two zoom behaviours. If you declared it in XAML, you should be able to see it in the WPF Designer.


Congratulations, you have just created your first SciChartSurface!




SCICHART ® is a Registered Trademark in the UK, US and EEC. Copyright SciChart Ltd 2011-2016.

Email us to give feedback!