--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/visjs/src/cz/functionals/visjs/DataSet.scala Wed Aug 28 21:14:32 2019 +0200
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2019 Tomas Zeman <tomas@functionals.cz>, <tzeman@volny.cz>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package cz.functionals.visjs
+
+import scala.scalajs.js
+import scala.scalajs.js.annotation.JSGlobal
+
+@js.native
+@JSGlobal("vis.DataSet")
+class DataSet[T](v: js.Array[T]) extends js.Any {
+ def add(v: T): Unit = js.native
+ def add(l: js.Array[T]): Unit = js.native
+ def clear(): Unit = js.native
+ def get(): js.Array[T] = js.native
+ def get(id: String): T = js.native // may return null
+ def get(ids: js.Array[String]): js.Array[T] = js.native // may return null elements
+ def update(v: T): Unit = js.native
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/visjs/src/cz/functionals/visjs/Graph2d.scala Wed Aug 28 21:14:32 2019 +0200
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2019 Tomas Zeman <tomas@functionals.cz>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package cz.functionals.visjs
+
+import org.scalajs.dom.Node
+
+import scala.scalajs.js
+import scala.scalajs.js.annotation.JSGlobal
+
+@js.native
+@JSGlobal("vis.Graph2d")
+class Graph2d(container: Node, data: DataSet[_],
+ options: js.Object = new js.Object) extends js.Object {
+
+ def fit(): Unit = js.native
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/visjs/src/cz/functionals/visjs/GraphEdge.scala Wed Aug 28 21:14:32 2019 +0200
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2019 Tomas Zeman <tomas@functionals.cz>, <tzeman@volny.cz>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package cz.functionals.visjs
+
+import scala.scalajs.js
+import scala.scalajs.js.UndefOr
+
+class GraphEdge(val from: String,
+ val to: String,
+ val label: UndefOr[String] = js.undefined,
+ val arrows: UndefOr[String] = js.undefined
+) extends js.Object
+
+object GraphEdge {
+ sealed abstract class Arrow(val v: String)
+ case object From extends Arrow("from")
+ case object To extends Arrow("to")
+ case object Middle extends Arrow("middle")
+ object Arrows {
+ def apply(xs: Arrow*): String = xs.toSet mkString ","
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/visjs/src/cz/functionals/visjs/GraphNode.scala Wed Aug 28 21:14:32 2019 +0200
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2019 Tomas Zeman <tomas@functionals.cz>, <tzeman@volny.cz>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package cz.functionals.visjs
+
+import org.scalajs.dom
+
+import scala.scalajs.js
+import scala.scalajs.js.{UndefOr, |}
+
+class GraphNode(
+ val id: String,
+ val label: String,
+ val title: UndefOr[String|dom.Element] = js.undefined,
+ val color: UndefOr[String] = js.undefined,
+ val image: UndefOr[js.Any] = js.undefined,
+ val shape: UndefOr[String] = js.undefined)
+extends js.Object
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/visjs/src/cz/functionals/visjs/Interaction.scala Wed Aug 28 21:14:32 2019 +0200
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2019 Tomas Zeman <tomas@functionals.cz>, <tzeman@volny.cz>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package cz.functionals.visjs
+
+import scala.scalajs.js
+
+class Interaction(
+ val dragNodes: Boolean = true,
+ val dragView: Boolean = true,
+ val hideEdgesOnDrag: Boolean = false,
+ //(Unknown option detected) val hideEdgesOnZoom: Boolean = false,
+ val hideNodesOnDrag: Boolean = false,
+ val hover: Boolean = false,
+ val hoverConnectedEdges: Boolean = true,
+ val multiselect: Boolean = false,
+ val navigationButtons: Boolean = false,
+ val selectable: Boolean = true,
+ val selectConnectedEdges: Boolean = true,
+ val tooltipDelay: Int = 300,
+ val zoomView: Boolean = true
+) extends js.Object
+
+/*
+https://visjs.github.io/vis-network/docs/network/interaction.html#
+interaction:{
+ dragNodes:true,
+ dragView: true,
+ hideEdgesOnDrag: false,
+ hideEdgesOnZoom: false,
+ hideNodesOnDrag: false,
+ hover: false,
+ hoverConnectedEdges: true,
+ keyboard: {
+ enabled: false,
+ speed: {x: 10, y: 10, zoom: 0.02},
+ bindToWindow: true
+ },
+ multiselect: false,
+ navigationButtons: false,
+ selectable: true,
+ selectConnectedEdges: true,
+ tooltipDelay: 300,
+ zoomView: true
+ }
+ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/visjs/src/cz/functionals/visjs/Network.scala Wed Aug 28 21:14:32 2019 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2019 Tomas Zeman <tomas@functionals.cz>, <tzeman@volny.cz>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package cz.functionals.visjs
+
+import org.scalajs.dom.Node
+
+import scala.scalajs.js
+import scala.scalajs.js.JSConverters._
+import scala.scalajs.js.annotation.JSGlobal
+
+@js.native
+@JSGlobal("vis.Network")
+class Network(container: Node, data: NetworkData, options: NetworkOptions)
+ extends js.Object {
+ def destroy(): Unit = js.native
+ //def on(eventName: String, callback: js.Function1[js.Any, Unit]): Unit = js.native
+ def on[Ev](eventName: String, callback: js.Function1[Ev, Unit]): Unit = js.native
+ def setData(data: NetworkData): Unit = js.native
+}
+
+class NetworkOptions(
+ val physics: js.Object = new js.Object(), // must be defined
+ val interaction: Interaction = new Interaction()
+) extends js.Object
+
+/*
+https://visjs.org/docs/network/#options
+var options = {
+ autoResize: true,
+ height: '100%',
+ width: '100%'
+ locale: 'en',
+ locales: locales,
+ clickToUse: false,
+ configure: {...}, // defined in the configure module.
+ edges: {...}, // defined in the edges module.
+ nodes: {...}, // defined in the nodes module.
+ groups: {...}, // defined in the groups module.
+ layout: {...}, // defined in the layout module.
+ interaction: {...}, // defined in the interaction module.
+ manipulation: {...}, // defined in the manipulation module.
+ physics: {...}, // defined in the physics module.
+}
+ */
+
+trait NetworkData extends js.Object
+
+object NetworkData {
+ def apply(nodes: Seq[GraphNode], edges: Seq[GraphEdge]): NetworkData =
+ apply(new DataSet(nodes.toJSArray), new DataSet(edges.toJSArray))
+
+ def apply(nodes: DataSet[GraphNode], edges: DataSet[GraphEdge]): NetworkData =
+ js.Dynamic.literal(nodes = nodes, edges = edges).asInstanceOf[NetworkData]
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/visjs/src/cz/functionals/visjs/event.scala Wed Aug 28 21:14:32 2019 +0200
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2019 Tomas Zeman <tomas@functionals.cz>, <tzeman@volny.cz>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package cz.functionals.visjs
+
+import scala.scalajs.js
+
+class HoverNodeEvent(val node: String) extends js.Object {
+}