Skip to content

Commit

Permalink
Add surface trace for enabling 3d surface charts
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Streese committed Nov 21, 2019
1 parent 566abbb commit 46b256a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
3 changes: 3 additions & 0 deletions core/shared/src/main/scala/plotly/Sequence.scala
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[Doubles]) 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.map(v => Doubles(v)))
implicit def fromStringSeq(s: Seq[String]): Sequence =
Strings(s)
implicit def fromDateTimes(seq: Seq[LocalDateTime]): Sequence =
Expand Down
19 changes: 19 additions & 0 deletions core/shared/src/main/scala/plotly/Trace.scala
Expand Up @@ -235,3 +235,22 @@ object Histogram {
Option(histfunc)
)
}

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

object Surface {
def apply(
z: Sequence = null,
showscale: JBoolean = null,
opacity: JDouble = null
): Surface =
Surface(
Option(z),
Option(showscale) .map(b => b: Boolean),
Option(opacity) .map(d => d: Double)
)
}
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
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 46b256a

Please sign in to comment.