I am integrating scichart to my android project and facing this error. I need to display ohlc data so, base on this tutorial https://www.scichart.com/example/android-candlestick-chart-example/ I wrote
val dataSeries = OhlcDataSeries(Date::class.java, Double::class.java)
That was translated from java code
IOhlcDataSeries<Date, Double> dataSeries = new OhlcDataSeries<>(Date.class, Double.class);
I got this error
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.qh.cointracker, PID: 5275
java.util.NoSuchElementException: GenericClass doesn't support Class<double>
at com.scichart.data.numerics.math.GenericMathFactory.create(GenericMathFactory.java:65)
at com.scichart.charting.model.dataSeries.DataSeries.<init>(DataSeries.java:91)
at com.scichart.charting.model.dataSeries.XDataSeries.<init>(XDataSeries.java:58)
at com.scichart.charting.model.dataSeries.OhlcDataSeries.<init>(OhlcDataSeries.java:58)
at com.scichart.charting.model.dataSeries.OhlcDataSeries.<init>(OhlcDataSeries.java:73)
at com.qh.cointracker.activities.fragments.SymbolChartFragment.initExample(SymbolChartFragment.kt:57)
at com.qh.cointracker.activities.fragments.SymbolChartFragment.onViewCreated(SymbolChartFragment.kt:37)
Can someone give me any idea to solve this error
Thank you.
The problem is that your code is working with the corresponding primitive type. You can use the following property defined on KClass
instead:
/**
* Returns a Java [Class] instance corresponding to the given [KClass] instance.
* In case of primitive types it returns corresponding wrapper classes.
*/
public val <T : Any> KClass<T>.javaObjectType: Class<T>
As the KDoc describes, the corresponding wrapper type will be returned:
Double::class.javaObjectType //class java.lang.Double
I know its already answered, but for future reference:
There are examples of using SciChart Android Charts with Kotlin on their public github page. Under the v2.x -> Showcase folder
The EcgViewModel.kt shows how to create and fill XyDataSeries
The StockChartViewModel.kt shows how to create and fill OhlcDataSeries
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With