Permalink
Browse files

Switch to jupyter-scala 0.4.x

  • Loading branch information...
alexarchambault committed Nov 30, 2016
1 parent b736633 commit ecc2ba132a939f1760288fa36850c3684591b683
Showing with 13 additions and 19 deletions.
  1. +2 −2 build.sbt
  2. +11 −17 jupyter-scala/src/main/scala/plotly/JupyterScala.scala
View
@@ -1,5 +1,5 @@
val jupyterScalaVersion = "0.3.0-M3"
val jupyterScalaVersion = "0.4.0-RC1"
val circeVersion = "0.6.1"
val plotlyVersion = "1.12.0"
@@ -184,7 +184,7 @@ lazy val `jupyter-scala` = project
.settings(
name := "plotly-jupyter-scala",
libraryDependencies ++= Seq(
"com.github.alexarchambault.jupyter" % "scala-api" % jupyterScalaVersion % "provided" cross CrossVersion.full
"org.jupyter-scala" % "scala-api" % jupyterScalaVersion % "provided" cross CrossVersion.full
)
)
@@ -1,6 +1,6 @@
package plotly
import jupyter.api.{ Publish, Evidence }
import jupyter.api.Publish
import java.lang.{ Integer => JInt, Double => JDouble, Boolean => JBoolean }
@@ -11,7 +11,7 @@ import plotly.layout._
object JupyterScala {
def init(offline: Boolean = false)(implicit publish: Publish[Evidence], ev: Evidence): Unit = {
def init(offline: Boolean = false)(implicit publish: Publish): Unit = {
// offline mode like in plotly-python
@@ -47,16 +47,15 @@ object JupyterScala {
</script>
"""
publish.display("", "text/html" -> html)
publish.html(html)
}
def plotJs(
div: String,
data: Seq[Trace],
layout: Layout
)(implicit
publish: Publish[Evidence],
ev: Evidence
publish: Publish
): Unit = {
val baseJs = Plotly.jsSnippet(div, data, layout)
@@ -66,7 +65,7 @@ object JupyterScala {
| $baseJs
|});
""".stripMargin
publish.display("", "application/javascript" -> js)
publish.js(js)
}
def randomDiv() = "plot-" + math.abs(Random.nextInt().toLong)
@@ -76,8 +75,7 @@ object JupyterScala {
layout: Layout = Layout(),
div: String = ""
)(implicit
publish: Publish[Evidence],
ev: Evidence
publish: Publish
): String = {
val div0 =
@@ -87,7 +85,7 @@ object JupyterScala {
div
if (div.isEmpty)
publish.display("", "text/html" -> s"""<div class="chart" id="$div0"></div>""")
publish.html(s"""<div class="chart" id="$div0"></div>""")
plotJs(div0, data, layout)
@@ -125,8 +123,7 @@ object JupyterScala {
boxmode: BoxMode = null,
div: String = ""
)(implicit
publish: Publish[Evidence],
ev: Evidence
publish: Publish
): String =
plot(
Layout(
@@ -164,8 +161,7 @@ object JupyterScala {
layout: Layout,
div: String
)(implicit
publish: Publish[Evidence],
ev: Evidence
publish: Publish
): String =
JupyterScala.plot(Seq(data), layout, div = div)
}
@@ -200,8 +196,7 @@ object JupyterScala {
boxmode: BoxMode = null,
div: String = ""
)(implicit
publish: Publish[Evidence],
ev: Evidence
publish: Publish
): String =
plot(
Layout(
@@ -239,8 +234,7 @@ object JupyterScala {
layout: Layout,
div: String
)(implicit
publish: Publish[Evidence],
ev: Evidence
publish: Publish
): String =
JupyterScala.plot(data, layout, div = div)
}

0 comments on commit ecc2ba1

Please sign in to comment.