Has anybody experience with plotly.kt on frontend ...
# javascript
f
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
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
@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
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
@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
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
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
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
I actually meant my .kt files in my kotlin-js frontend.
a
OK, then could you explain what is going wrong? The example above should cover most needs.
f
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
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
@altavir Thanks, I’ll try to debug that. Have a good day