alexarchambault / plotly-scala

Scala bindings for plotly.js
http://plotly-scala.org
221 stars 48 forks source link

jupyter with toree kernel #14

Open spmp opened 7 years ago

spmp commented 7 years ago

I am trying your examples in a jupyter notebook using Toree and having a few issues:

  1. I cannot add plotly-render and plotly-core from maven coordinates. It works with URL to the jar:
    // Does not work
    //%AddDeps org.plotly-scala plotly-core 0.3.1
    //%AddDeps org.plotly-scala plotly-render 0.3.1
    // Does work
    %AddDeps org.plotly-scala plotly-jupyter-scala_2.11 0.3.2
    %AddJar http://central.maven.org/maven2/org/plotly-scala/plotly-core_2.11/0.3.2/plotly-core_2.11-0.3.2.jar
    %AddJar http://central.maven.org/maven2/org/plotly-scala/plotly-render_2.11/0.3.2/plotly-render_2.11-0.3.2.jar
  2. A current limitation (maybe soon to be fixed) is the inability for Toree to successfully get the full dependency tree (--transitive) form a maven coordinate. What other dependencies should be fetched for Plotly?
  3. I cannot get any examples to work with the combination of Jupyter and Toree:
    
    import plotly._
    import plotly.element._
    import plotly.layout._
    import plotly.JupyterScala._

plotly.JupyterScala.init()

Name: Compile Error Message: :95: error: erroneous or inaccessible type val res106 = ^ StackTrace:

or from the demo:

val trace1 = Scatter( Seq(1, 2, 3, 4), Seq(10, 15, 13, 17) ) val trace2 = Scatter( Seq(1, 2, 3, 4), Seq(16, 5, 11, 9) ) val data = Seq(trace1, trace2) Plotly.plot("div-id", data)

Name: Compile Error Message: :108: error: not enough arguments for method plot: (path: String, traces: Seq[plotly.Trace], layout: plotly.layout.Layout, useCdn: Boolean, openInBrowser: Boolean, addSuffixIfExists: Boolean)java.io.File. Unspecified value parameter layout. Plotly.plot("div-id", data) ^ StackTrace:

oooh, this is more explicit a stack trace from the above:

Name: Compile Error Message: error: missing or invalid dependency detected while loading class file 'JupyterScala.class'. Could not access term jupyter in package , because it (or its dependencies) are missing. Check your build definition for missing or conflicting dependencies. (Re-run with -Ylog-classpath to see the problematic classpath.) A full rebuild may help if 'JupyterScala.class' was compiled against an incompatible version of . error: missing or invalid dependency detected while loading class file 'JupyterScala.class'. Could not access type Publish in value .api, because it (or its dependencies) are missing. Check your build definition for missing or conflicting dependencies. (Re-run with -Ylog-classpath to see the problematic classpath.) A full rebuild may help if 'JupyterScala.class' was compiled against an incompatible version of .api. error: missing or invalid dependency detected while loading class file 'JupyterScala.class'. Could not access term api in value jupyter, because it (or its dependencies) are missing. Check your build definition for missing or conflicting dependencies. (Re-run with -Ylog-classpath to see the problematic classpath.) A full rebuild may help if 'JupyterScala.class' was compiled against an incompatible version of jupyter.

:43: error: could not find implicit value for parameter publish: .api.Publish plotly.JupyterScala.init() ^ StackTrace: ``` Version is: ``` jupyter --version 4.3.0 ``` If I add the Layout: ``` val plotlyLayout = layout.Layout() Plotly.plot("div-id", data, plotlyLayout) Name: java.lang.NoClassDefFoundError Message: io/circe/Printer$ StackTrace: at plotly.Plotly$.(Plotly.scala:19) at plotly.Plotly$.(Plotly.scala) ... 54 elided Caused by: java.lang.ClassNotFoundException: io.circe.Printer$ at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ``` or try an example that has a layout ``` val trace1 = Bar( Seq("giraffes", "orangutans", "monkeys"), Seq(20, 14, 23), name = "SF Zoo" ) val trace2 = Bar( Seq("giraffes", "orangutans", "monkeys"), Seq(12, 18, 29), name = "LA Zoo" ) val data = Seq(trace1, trace2) val layout = Layout( barmode = BarMode.Group ) Plotly.plot("div-id", data, layout) Name: java.lang.NoClassDefFoundError Message: Could not initialize class plotly.Plotly$ StackTrace: ``` 4. Are there any niceties that may work well with Spark DataFrames? 5. Does Plotly have any _graphs_/_charts_ like D3 force for visualising graphs? 6. Is this implementation of Plotly completely offline? Cheers.
rzykov commented 6 years ago

We solved it here https://github.com/RetailRocket/ToreeExt

spmp commented 6 years ago

Awesome, I will check it out soon.

spmp commented 6 years ago

The example does not work for me. Will comment on that project and report success back here.

Pioneer-Weirdo commented 2 years ago

Did you solve it?

Armadik commented 1 year ago

Did you solve it?