SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components

1
0

Hello,

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,
Bart

Version
3.0.0.4239
  • You must to post comments
0
1

Hi Bart,

This happens because Double.class returns Kotlin class for Double and DataSeries expects Java class passed into constructor.

For convenience you can use next approach and create a helper for creation of data series and use it instead of XyDataSeries constructor:

inline fun <reified TX : Comparable<TX>, reified TY : Comparable<TY>> XyDataSeries(): XyDataSeries<TX, TY> {
       return XyDataSeries(TX::class.javaObjectType, TY::class.javaObjectType)
}

Then define data series using this helper:

private val linedata2 =  XyDataSeries<Double, Double>()

Hope this will help you!

Best regards,
Yura

  • You must to post comments
0
0

Thank you! It works now!

  • Abhishek Chaudhary
    if We use above mentioned helper then at time of build we are getting type issue in passing dataSeries into 3d chart. //helper inline fun <reified TX : Comparable, reified TY : Comparable, reified TZ : Comparable> XYZDataSeries(): XyzDataSeries { return XyzDataSeries( TX::class.javaObjectType, TY::class.javaObjectType, TZ::class.javaObjectType ) } //data series val dataSeries = XYZDataSeries() for (i in 0..5) { var x: Double = i.toDouble() var y: Double = i.toDouble() var z: Double = i.toDouble() dataSeries.append(x, y, z) } //building var rs: FreeSurfaceRenderableSeries3D = sciChart3DBuilder.newFreeSurfaceSeries3D() .withDataSeries(dataSeries) .withPointMarker(pointMarker3D) .build()
  • Yura Khariton
    I don’t see generic params in your XYZDataSeries() call – there should be 3 generic params ( val dataSeries = XYZDataSeries() ). Also I don’t see generic params in return type for XYZDataSeries method – you just return XyzDataSeries instead of XyzDataSeries
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.