SciChart Android 2D Charts API > SciChart Android Basics > Chart Builders Helper Classes
Chart Builders Helper Classes

To simplify creation and configuring of a SciChartSurface, SciChart Android provides a bunch of helper classes. They follow the XXXBuilder naming pattern and allow to initialize virtually anything in an easier and more convenient way. Different property of classes can be preset via the withXXX(…) methods of the helpers, a.k.a. "chart builders".


Referencing SciChart Builders

SciChart builders for 2D charts provided as seperate library which is called 'extensions'. If you want to use then you'll need to add it into your project as dependency. This is available from our Maven feed, or in the Android Charts SDK at

Adding extension library
Copy Code
dependencies {         
     // Declare SciChart libraries as module dependencies
     implementation (name:'charting-release', ext:'aar')
     implementation (name:'drawing-release', ext:'aar')
     implementation (name:'data-release', ext:'aar')
     implementation (name:'core-release', ext:'aar'
     // Declare SciChart extension library as module dependencies
     implementation (name:'extensions-release', ext:'aar')

Using Chart Builders in Code

The main chart builder class is called SciChartBuilder. It acts as a factory of builders of other types, representing different chart aspects.

Using chart builders, the code snippet for chart initialization from the section above can be rewritten as follows:

Copy Code
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout from “base_scichart_layout.xml”
    View view = inflater.inflate(R.layout.base_scichart_layout, container, false);

    // find the surface by id
    SciChartSurface surface = (SciChartSurface) view.findViewById(;
    // need to init SciChartBuilder class with application context before using
    // obtain the SciChartBuilder instance
    final SciChartBuilder sciChartBuilder = SciChartBuilder.instance();

    // create numeric X axis
    final IAxis xAxis = sciChartBuilder.newNumericAxis()
            .withAxisTitle("X Axis Title")
            .withVisibleRange(-5, 15)

    // create a numeric Y axis
    final IAxis yAxis = sciChartBuilder.newNumericAxis()
            .withAxisTitle("Y Axis Title").withVisibleRange(0, 100).build();

    // create a TextAnnotation and specify the inscription and position for it
    TextAnnotation textAnnotation = sciChartBuilder.newTextAnnotation()
            .withText("Hello World!")
            .withFontStyle(10, ColorUtil.White)

    // create interactivity modifiers
    ModifierGroup chartModifiers = sciChartBuilder.newModifierGroupWithDefaultModifiers().build();

    // add the Y axis to the YAxes collection of the surface
    Collections.addAll(surface.getYAxes(), yAxis);

    // add the X axis to the XAxes collection of the surface
    Collections.addAll(surface.getXAxes(), xAxis);

    // add the annotation to the Annotations collection of the surface
    Collections.addAll(surface.getAnnotations(), textAnnotation);

    // add the interactions to the ChartModifiers collection of the surface
    Collections.addAll(surface.getChartModifiers(), chartModifiers);

    return view;

Usually this approach to chart initialization results in more concise and elegent code. It is preferred for the vast majority of examples from the Android Examples Suite. We would recommend using it in applications too. However, it doesn't give any other benefits except those stated above, so the standard way of objects initialization is equally fine.

See Also