Skip to content

Commit

Permalink
Merge pull request #134 from maxstreese/feature/3d-surface
Browse files Browse the repository at this point in the history
3d Surface Plots
  • Loading branch information
alexarchambault authored Nov 22, 2019
2 parents 264cd2b + 9beec14 commit e8eb0dd
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 5 deletions.
3 changes: 3 additions & 0 deletions core/shared/src/main/scala/plotly/Sequence.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ sealed abstract class Sequence extends Product with Serializable

object Sequence {
final case class Doubles(seq: Seq[Double]) extends Sequence
final case class NestedDoubles(seq: Seq[Seq[Double]]) extends Sequence
final case class Strings(seq: Seq[String]) extends Sequence
final case class DateTimes(seq: Seq[LocalDateTime]) extends Sequence

Expand All @@ -17,6 +18,8 @@ object Sequence {
Doubles(s.map(_.toDouble))
implicit def fromLongSeq(s: Seq[Long]): Sequence =
Doubles(s.map(_.toDouble))
implicit def fromNestedDoubleSeq(s: Seq[Seq[Double]]): Sequence =
NestedDoubles(s)
implicit def fromStringSeq(s: Seq[String]): Sequence =
Strings(s)
implicit def fromDateTimes(seq: Seq[LocalDateTime]): Sequence =
Expand Down
25 changes: 25 additions & 0 deletions core/shared/src/main/scala/plotly/Trace.scala
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,28 @@ object Histogram {
Option(histfunc)
)
}

@data class Surface(
x: Option[Sequence],
y: Option[Sequence],
z: Option[Sequence],
showscale: Option[Boolean],
opacity: Option[Double]
) extends Trace

object Surface {
def apply(
x: Sequence = null,
y: Sequence = null,
z: Sequence = null,
showscale: JBoolean = null,
opacity: JDouble = null
): Surface =
Surface(
Option(x),
Option(y),
Option(z),
Option(showscale) .map(b => b: Boolean),
Option(opacity) .map(d => d: Double)
)
}
10 changes: 7 additions & 3 deletions core/shared/src/main/scala/plotly/layout/Layout.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ import dataclass.data
bargap: Option[Double],
bargroupgap: Option[Double],
hovermode: Option[HoverMode],
boxmode: Option[BoxMode]
boxmode: Option[BoxMode],
scene: Option[Scene]

)

object Layout {
Expand Down Expand Up @@ -62,7 +64,8 @@ object Layout {
bargap: JDouble = null,
bargroupgap: JDouble = null,
hovermode: HoverMode = null,
boxmode: BoxMode = null
boxmode: BoxMode = null,
scene: Scene = null
): Layout =
new Layout(
Option(title),
Expand Down Expand Up @@ -90,6 +93,7 @@ object Layout {
Option(bargap).map(x => x),
Option(bargroupgap).map(x => x),
Option(hovermode),
Option(boxmode)
Option(boxmode),
Option(scene)
)
}
25 changes: 25 additions & 0 deletions core/shared/src/main/scala/plotly/layout/Scene.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package plotly
package layout

import java.lang.{ Integer => JInt, Double => JDouble, Boolean => JBoolean }

import dataclass.data
import plotly.element._

@data class Scene(
xaxis: Option[Axis],
yaxis: Option[Axis],
zaxis: Option[Axis]
)

object Scene {
def apply(
xaxis: Axis = null,
yaxis: Axis = null,
zaxis: Axis = null
): Scene = new Scene(
Option(xaxis),
Option(yaxis),
Option(zaxis)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ object ArgonautCodecsInternals extends ArgonautCodecsExtra {
implicit val boxMeanBoolIsWrapper: IsWrapper[BoxMean.Bool] = null
implicit val boxPointsBoolIsWrapper: IsWrapper[BoxPoints.Bool] = null
implicit val sequenceDoublesIsWrapper: IsWrapper[Sequence.Doubles] = null
implicit val sequenceNestedDoublesIsWrapper: IsWrapper[Sequence.NestedDoubles] = null
implicit val sequenceStringsIsWrapper: IsWrapper[Sequence.Strings] = null
implicit val sequenceDatetimesIsWrapper: IsWrapper[Sequence.DateTimes] = null
implicit val doubleElementIsWrapper: IsWrapper[Element.DoubleElement] = null
Expand Down
4 changes: 2 additions & 2 deletions tests/src/test/scala/plotly/doc/DocumentationTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,10 @@ class DocumentationTests extends FlatSpec with Matchers {
// TODO Heatmaps
// TODO Heatmap and contour colorscales
// TODO Polar charts
"scientific/log"
"scientific/log",
// TODO Financial charts
// TODO Maps
// TODO 3D charts
"3d/3d-surface"
)

val subDirs = subDirNames.map(new File(dir, _))
Expand Down

0 comments on commit e8eb0dd

Please sign in to comment.