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



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,

  • You must 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,

  • You must to post comments

Thank you! It works now!

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.