Pre loader

What is the equivalent to append data to an XyDataSeries in Kotlin on Android?

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums


I have been following the tutorials and in Tutorial 3 I have come to the point where data is added to an XyDataSeries and need to know the proper way to do it in Kotlin on Android (not Java).

In MainActivity.kt I have:

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {


    val surface = SciChartSurface(this)

    val chartLayout = findViewById<View>( as LinearLayout



    val sciChartBuilder = SciChartBuilder.instance()

    val xAxis = sciChartBuilder.newNumericAxis()
        .withAxisTitle("X Axis Title")
        .withVisibleRange(-5.0, 15.0)

    val yAxis = sciChartBuilder.newNumericAxis()
        .withAxisTitle("Y Axis Title")
        .withVisibleRange(0.0, 100.0)

    val textAnnotation = sciChartBuilder.newTextAnnotation()
        .withText("Hello World!")
        .withFontStyle(20f, ColorUtil.White)

    val chartModifiers = sciChartBuilder.newModifierGroup()

    // App crashes at the following point
    val lineData: XyDataSeries<Int, Double> = sciChartBuilder.newXyDataSeries(,

    // I presume this is also incorrect
    val scatterData: XyDataSeries<Int, Double> = sciChartBuilder.newXyDataSeries(,

    for (i in 0..999) {
        lineData.append(i, Math.sin(i * 0.1))
        scatterData.append(i, Math.cos(i * 0.1))

    val lineSeries = sciChartBuilder.newLineSeries()
        .withStrokeStyle(ColorUtil.LightBlue, 2f, true)


    Collections.addAll(surface.yAxes, yAxis);
    Collections.addAll(surface.xAxes, xAxis);
    Collections.addAll(surface.annotations, textAnnotation);
    Collections.addAll(surface.chartModifiers, chartModifiers);



The app crashes at the lines “val lineData: XyDataSeries<Int, Double> = sciChartBuilder.newXyDataSeries( …”. What is wrong here?

  • You must to post comments

I have found a solution given someone before me has had the same problem.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.