The root 2D chart view is called the SciChartSurface. This is the Android ViewGroup 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.
Are you new to SciChart? Check out our most popular pages to get started below:
Declaring a SciChartSurface Instance
Once the SciChart AARs are added as dependencies to an application’s build configuration, a SciChartSurface instance can be declared in a layout file using the following markup:
Layout file |
Copy Code |
---|---|
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <com.scichart.charting.visuals.SciChartSurface android:id="@+id/chart" android:layout_width="fill_parent" android:layout_height="fill_parent" /> </LinearLayout> |
Then, it can be accessed in code (assuming the layout file is called “base_scichart_layout.xml”) for further manipulations:
To summarize, the code above declares a SciChartSurface, adds two numeric axes, X and Y, onto it, adds a single text annotation and two zoom behaviours:
Also, the surface should appear in the design view of Android Studio.
Creating a SciChartSurface Instance in Code
Process of creation and configuring a SciChartSurface instance in code is essentially the same and quite straightforward. To make it even easier, SciChart Android provides a bunch of helper classes called Chart Builders. Please see the Chart Builders Helper Classes article for more details.
What's Next?
To learn more about how to configure SciChartSurface further, please refer to the following documentation sections:
For a step-by-step instruction on how to create a simple application with SciChart, please see the Quickstart Guide. Also, there are over 30 chart examples that can be found in the downloadable SciChart Android Examples Suite.