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
- Bart Bierling asked 5 years ago
- last edited 5 years ago
- You must login to post comments
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
- Yura Khariton answered 5 years ago
- You must login to post comments
Thank you! It works now!
- Bart Bierling answered 5 years ago
- 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()
- 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 login to post comments
Please login first to submit.