https://github.com/openmole/scala-js-plotlyjs
Scala.js facades for plotly.js .
https://github.com/openmole/scala-js-plotlyjs
Last synced: 10 months ago
JSON representation
Scala.js facades for plotly.js .
- Host: GitHub
- URL: https://github.com/openmole/scala-js-plotlyjs
- Owner: openmole
- License: agpl-3.0
- Created: 2017-10-05T12:06:10.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-12-08T15:38:21.000Z (over 2 years ago)
- Last Synced: 2025-04-11T17:00:02.597Z (about 1 year ago)
- Language: Scala
- Size: 117 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
scala-js-plotlyjs
===============
[](https://www.scala-js.org/)
Scala.js facades for [plotly.js](https://plot.ly/javascript/).
Usage
-----
First, add the JCenter resolver to your build file:
```
resolvers += Resolver.jcenterRepo,
```
Then, add it to your SBT dependencies:
```
libraryDependencies += "org.openmole" %%% "scala-js-plotlyjs" % "1.6.2"
```
This project provides Scala.js facades. The plotly.js (2.8.2) file resources is embedd in the jars through the jsDependency sbt plugin.
Demo
------
[Plotly demo](https://web.openmole.org/leclaire/plotly-demo.html)
Sources: [https://github.com/openmole/scala-js-plotlyjs-demo](https://github.com/openmole/scala-js-plotlyjs-demo)
Example
-------
```scala
val plotDiv = div()
val layout = Layout
.title("My line plot")
.showlegend(true)
.xaxis(axis.title("Time"))
.yaxis(axis.title("Production"))
val data = linechart.lines
val ref = Utils.randomDoubles(15, 10)
val dataRef = data
.x((0 to 14).toJSArray)
.y(ref)
.marker(marker.symbol(square).color(all.color.rgb(180, 0, 0)).size(12.0))
.name("Reds")
val dataN = (for (i <- 1 to 6) yield {
data
.x((0 to 14).toJSArray)
.y(ref.map { x => x + Utils.rng.nextDouble * 2 - 1 }.toJSArray)
.marker(marker.size(10.0).color(all.color.rgb(200, 136, 170)))
._result
}).toJSArray
val config = Config.displayModeBar(false)
Plotly.newPlot(plotDiv.ref,
dataN :+ dataRef._result,
layout,
config)
plotDiv
```