JetBrains / lets-plot-kotlin

Grammar of Graphics for Kotlin
https://lets-plot.org/kotlin/
MIT License
430 stars 36 forks source link

Intellij IDEA scratch file/worksheet support? #49

Closed jsnelgro closed 2 years ago

jsnelgro commented 4 years ago

I'm not sure where the best place to ask this is, but has there been work towards adding lets-plot capabilities to Intellij IDEA's Kotlin scratch files? I use scratch files on the daily and being able to quickly plot something without having to set up a new project environment or switch contexts would be huge. Thanks for your great work!

alshan commented 4 years ago

This is an interesting idea. We were planning to build an IDEA plugin similar to Lets-Plot in SciView but the Kotlin scratch files are different - I'm not sure that plugin can target scratches. This need to be researched. The question is how to add lets-plot jars to the scratch classpath. Scratch can use a module classpath but a necessity to create a module is probably denies the whole point.

alshan commented 3 years ago

Hi @jsnelgro, since v1.3.0 the plot.show() opens a simple plot viewer window. But you have to make sure that either

is in your classpath (in addition to required "org.jetbrains.lets-plot:lets-plot-common:2.0.1" and "org.jetbrains.lets-plot-kotlin:lets-plot-kotlin-api:1.3.0").

This should work in Kotlin scratch files as well. Please checkout v1.3.0.

jsnelgro commented 3 years ago

hey @alshan, this couldn't have come at a better time! Thank you, y'all are awesome! I simply added the dependencies you mentioned, set the scratch file classpath and voila, drew a nice little chart 😄 image

Note: I had to use the JavaFX backend. Batik couldn't find a dependency, but that's probably more related to how I added the jars to my classpath (had to manually download and add them since my company has its own nexus server and lets-plot isn't on there)

alshan commented 3 years ago

Very good! Yes, Batik requires quite a few artifacts - manually configuring would be tedious.

image