https://kotlinlang.org logo
#javascript
Title
# javascript
f

Florent Martin

07/07/2022, 12:06 PM
Has anybody experience with plotly.kt on frontend side? I am working on a multiplatform app and am trying to add the plotly.kt dependencies to the frontend (react/js). I am not able to use this example here: https://github.com/mipt-npm/plotly.kt/blob/master/examples/js-demo/build.gradle.kts, I think “implementation(project(“:plotlykt-core”))” is wrong for me. My Setup is also with Kotlin 1.7 which might be a problem too.
a

altavir

07/07/2022, 4:16 PM
Do you try to just copy it with
project
thing? From extenral project it should work like
implementation("space.kscience:plotlykt-core:0.5.2")
I have not checked the JS part on 1.7, but it should work
0.5.1, sorry
Or even 0.5.0 if you are using mavenCentral
OK, 0.5.1 has only dev branches, so it is 0.5.0 anyway
f

Florent Martin

07/07/2022, 4:22 PM
@altavir Thanks, that’s what I have tried but i keep getting the error “No matching variant of space.kscienceplotlykt core0.5.0 was found.” when adding it in my frontend dependencies
a

altavir

07/07/2022, 4:31 PM
OK. Let me check it.
Ah, I have an idea @Florent Martin do you use LEGACY JS backend per chance? Plotly-kt does not support it. You need to use
js(IR)
in target configuration
I need to add it to the README
Here is a working stand-alone demo: https://github.com/altavir/plotly-kt-js-demo
f

Florent Martin

07/08/2022, 6:01 AM
@altavir You are right, I am using LEGACY because of very slow hot-reloading in IR. I switched to IR and it wasn’t working at first but retrying made it work. Thank you
a

altavir

07/08/2022, 6:03 AM
You are welcome. I recommend moving to IR anyway. I think it will be the default soon.
And maintaining libraries in BOTH mode is a pain.
f

Florent Martin

07/08/2022, 6:10 AM
I guess we’ll have to move to IR yes
I could setup everything but I am unfortunately not able to import space.kscience[…] modules in my js-files. I guess this has something to do with our build.gradle.kts @altavir Any idea maybe what could cause this?
a

altavir

07/10/2022, 8:34 AM
Could you please explain it in more detail? Are you trying to use it from JS? It does not make a lot of sense since Plotly is JS library initially and it is much easier to use it directly without Kotlin overhead.
f

Florent Martin

07/10/2022, 8:36 AM
I actually meant my .kt files in my kotlin-js frontend.
a

altavir

07/10/2022, 8:39 AM
OK, then could you explain what is going wrong? The example above should cover most needs.
f

Florent Martin

07/10/2022, 8:45 AM
Basically I can add
import react.FC
using
implementation("org.jetbrains.kotlin-wrappers:kotlin-react")
but adding
import space.kscience.plotly.plot
using
implementation("space.kscience:plotlykt-core:0.5.0")
give me an error “Unresolved reference: space” as if I can only add specific dependency types
a

altavir

07/10/2022, 8:47 AM
It seems like something is broken in your build script. It is not a reference, it is a string.
Make sure you have matched quotes everywhere
f

Florent Martin

07/10/2022, 8:52 AM
@altavir Thanks, I’ll try to debug that. Have a good day
7 Views