Pre loader

Tag: Kotlin

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

1 vote

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?

0 votes


I would like to display all the hours of the day in X axis e.g 01 to 24 and I haven’t been able to achieve it yet, I tried use date delta but I couldn’t figure out how it really works, could you please share a code snippet or some example.


  • Anas Iqbal asked 2 years ago
  • last active 2 years ago
1 vote


I am trying to add series to a linechart, however I seem to be unable to create a XyDataSeries in Kotlin I have tried the following:

private val linedata = XyDataSeries<Double, Double>().apply { fifoCapacity = FIFO_CAPACITY } 

// like from the ECG showcase example, this gives the error 
// "none of the functions can be called with the arguments called"

private val linedata2 : IXyDataSeries<Double, Double> =  XyDataSeries(Double.class, Double.class)

private var linedata3 : XyDataSeries<Double, Double> = XyDataSeries(Integer.class, Double.class).build()

This seems quite straightforward but I am unable to find a solution. Can you help me?

Kind regards,

Showing 3 results