aboutsummaryrefslogtreecommitdiff
path: root/examples/scalajs-plain-example/js/App.scala
blob: 71a285ee5b37b97a5030c6b2fe04204cead3f417 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package prototype

import org.scalajs.dom

import scala.scalajs.js
import scala.scalajs.js.JSON
import scala.scalajs.js.JSApp
import scala.scalajs.js.annotation.JSExport

@JSExport("App")
object App extends JSApp {
  def main(): Unit = {
    val trace1 = """{
                 |  "x": [1, 2, 3, 4],
                 |  "y": [10, 15, 13, 17],
                 |  "type": "scatter"
                 |}  """.stripMargin
     val trace2 = """{
                   | "x": [1, 2, 3, 4],
                   |  "y": [16, 5, 11, 9],
                   |  "type": "scatter"
                   |}  """.stripMargin
     val data = js.Array(trace1, trace2).map(trace => JSON.parse(trace))
     val doc = dom.document
     Plotly.newPlot("plotly", data)
  }
}