Pre loader

Tag: Kotlin

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 11 months ago
  • last active 10 months 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

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies