Permalink
Browse files

Switch to plotly.js 1.41.3

And run the tests against the latest documentation
  • Loading branch information...
alexarchambault committed Oct 5, 2018
1 parent 58dde02 commit ad3b283e722367600774671d7ec520d7cee9d994
@@ -11,7 +11,7 @@ sealed abstract class Trace extends Product with Serializable
final case class Scatter(
x: Option[Sequence],
y: Option[Sequence],
text: Option[Seq[String]],
text: Option[OneOrSeq[String]],
mode: Option[ScatterMode],
marker: Option[Marker],
line: Option[Line],
@@ -24,27 +24,37 @@ final case class Scatter(
fill: Option[Fill],
error_x: Option[Error],
error_y: Option[Error],
showlegend: Option[Boolean]
showlegend: Option[Boolean],
fillcolor: Option[OneOrSeq[Color]],
hoverinfo: Option[HoverInfo],
hoveron: Option[HoverOn],
stackgroup: Option[String],
groupnorm: Option[GroupNorm]
) extends Trace
object Scatter {
def apply(
values: Sequence = null,
secondValues: Sequence = null,
text: Seq[String] = null,
mode: ScatterMode = null,
marker: Marker = null,
line: Line = null,
textposition: TextPosition = null,
textfont: TextFont = null,
name: String = null,
connectgaps: JBoolean = null,
xaxis: AxisReference = null,
yaxis: AxisReference = null,
fill: Fill = null,
error_x: Error = null,
error_y: Error = null,
showlegend: JBoolean = null
values: Sequence = null,
secondValues: Sequence = null,
text: OneOrSeq[String] = null,
mode: ScatterMode = null,
marker: Marker = null,
line: Line = null,
textposition: TextPosition = null,
textfont: TextFont = null,
name: String = null,
connectgaps: JBoolean = null,
xaxis: AxisReference = null,
yaxis: AxisReference = null,
fill: Fill = null,
error_x: Error = null,
error_y: Error = null,
showlegend: JBoolean = null,
fillcolor: OneOrSeq[Color] = null,
hoverinfo: HoverInfo = null,
hoveron: HoverOn = null,
stackgroup: String = null,
groupnorm: GroupNorm = null
): Scatter = {
val (xOpt, yOpt) = Option(secondValues) match {
@@ -68,7 +78,12 @@ object Scatter {
Option(fill),
Option(error_x),
Option(error_y),
Option(showlegend) .map(b => b: Boolean)
Option(showlegend) .map(b => b: Boolean),
Option(fillcolor),
Option(hoverinfo),
Option(hoveron),
Option(stackgroup),
Option(groupnorm)
)
}
}
@@ -123,30 +138,40 @@ object Box {
}
final case class Bar(
x: Sequence,
y: Sequence,
name: Option[String],
text: Option[Seq[String]],
marker: Option[Marker],
orientation: Option[Orientation],
xaxis: Option[AxisReference],
yaxis: Option[AxisReference],
error_y: Option[Error],
showlegend: Option[Boolean]
x: Sequence,
y: Sequence,
name: Option[String],
text: Option[Seq[String]],
marker: Option[Marker],
orientation: Option[Orientation],
xaxis: Option[AxisReference],
yaxis: Option[AxisReference],
error_y: Option[Error],
showlegend: Option[Boolean],
hoverinfo: Option[HoverInfo],
textposition: Option[BarTextPosition],
opacity: Option[Double],
width: Option[OneOrSeq[Double]],
base: Option[OneOrSeq[Double]]
) extends Trace
object Bar {
def apply(
x: Sequence,
y: Sequence,
name: String = null,
text: Seq[String] = null,
marker: Marker = null,
orientation: Orientation = null,
xaxis: AxisReference = null,
yaxis: AxisReference = null,
error_y: Error = null,
showlegend: JBoolean = null
x: Sequence,
y: Sequence,
name: String = null,
text: Seq[String] = null,
marker: Marker = null,
orientation: Orientation = null,
xaxis: AxisReference = null,
yaxis: AxisReference = null,
error_y: Error = null,
showlegend: JBoolean = null,
hoverinfo: HoverInfo = null,
textposition: BarTextPosition = null,
opacity: JDouble = null,
width: OneOrSeq[Double] = null,
base: OneOrSeq[Double] = null
): Bar =
Bar(
x,
@@ -158,7 +183,12 @@ object Bar {
Option(xaxis),
Option(yaxis),
Option(error_y),
Option(showlegend).map(b => b: Boolean)
Option(showlegend).map(b => b: Boolean),
Option(hoverinfo),
Option(textposition),
Option(opacity).map(d => d: Double),
Option(width),
Option(base)
)
}
@@ -171,20 +201,24 @@ case class Histogram(
marker: Option[Marker],
xbins: Option[Bins],
histnorm: Option[HistNorm],
showlegend: Option[Boolean]
showlegend: Option[Boolean],
cumulative: Option[Cumulative],
histfunc: Option[HistFunc]
) extends Trace
object Histogram {
def apply(
x: Sequence = null,
y: Sequence = null,
opacity: JDouble = null,
name: String = null,
autobinx: JBoolean = null,
marker: Marker = null,
xbins: Bins = null,
histnorm: HistNorm = null,
showlegend: JBoolean = null
x: Sequence = null,
y: Sequence = null,
opacity: JDouble = null,
name: String = null,
autobinx: JBoolean = null,
marker: Marker = null,
xbins: Bins = null,
histnorm: HistNorm = null,
showlegend: JBoolean = null,
cumulative: Cumulative = null,
histfunc: HistFunc = null
): Histogram =
Histogram(
Option(x),
@@ -195,6 +229,8 @@ object Histogram {
Option(marker),
Option(xbins),
Option(histnorm),
Option(showlegend) .map(b => b: Boolean)
Option(showlegend) .map(b => b: Boolean),
Option(cumulative),
Option(histfunc)
)
}
@@ -0,0 +1,11 @@
package plotly
package element
sealed abstract class BarTextPosition(val label: String) extends Product with Serializable
object BarTextPosition {
case object Inside extends BarTextPosition("inside")
case object Outside extends BarTextPosition("outside")
case object Auto extends BarTextPosition("auto")
case object None extends BarTextPosition("none")
}
@@ -15,7 +15,11 @@ object Color {
"grey",
"white",
"fuchsia",
"red"
"red",
"blue",
"cls", // ???
"pink",
"green"
)
}
@@ -0,0 +1,3 @@
package plotly.element
final case class Cumulative(enabled: Boolean)
@@ -4,6 +4,11 @@ package element
sealed abstract class Fill(val label: String) extends Product with Serializable
object Fill {
case object None extends Fill("none")
case object ToZeroX extends Fill("tozerox")
case object ToZeroY extends Fill("tozeroy")
case object ToNextX extends Fill("tonextx")
case object ToNextY extends Fill("tonexty")
case object ToSelf extends Fill("toself")
case object ToNext extends Fill("tonext")
}
@@ -0,0 +1,8 @@
package plotly.element
sealed abstract class GroupNorm(val label: String) extends Product with Serializable
object GroupNorm {
case object Fraction extends GroupNorm("fraction")
case object Percent extends GroupNorm("percent")
}
@@ -0,0 +1,13 @@
package plotly.element
sealed abstract class HistFunc(val label: String) extends Product with Serializable
object HistFunc {
case object Count extends HistFunc("count")
case object Sum extends HistFunc("sum")
case object Average extends HistFunc("avg")
case object Min extends HistFunc("min")
case object Max extends HistFunc("max")
}
@@ -0,0 +1,37 @@
package plotly.element
sealed abstract class HoverInfo extends Product with Serializable {
def label: String
}
object HoverInfo {
def all: HoverInfo = All
def none: HoverInfo = None
def skip: HoverInfo = Skip
def apply(elements: Element*): HoverInfo =
Combination(elements)
sealed abstract class Element(override val label: String) extends HoverInfo
case object X extends Element("x")
case object Y extends Element("y")
case object Z extends Element("z")
case object Text extends Element("text")
case object Name extends Element("name")
case object All extends HoverInfo {
def label = "all"
}
val None = Combination(Nil)
case object Skip extends HoverInfo {
def label = "skip"
}
final case class Combination(elements: Seq[Element]) extends HoverInfo {
def label: String = elements.map(_.label).mkString("+")
}
}
@@ -0,0 +1,9 @@
package plotly.element
sealed abstract class HoverOn(val label: String) extends Product with Serializable
object HoverOn {
case object Points extends HoverOn("points")
case object Fills extends HoverOn("fills")
case object PointsFill extends HoverOn("points+fills")
}
@@ -4,7 +4,8 @@ package layout
sealed abstract class BarMode(val label: String) extends Product with Serializable
object BarMode {
case object Group extends BarMode("group")
case object Stack extends BarMode("stack")
case object Overlay extends BarMode("overlay")
case object Group extends BarMode("group")
case object Stack extends BarMode("stack")
case object Overlay extends BarMode("overlay")
case object Relative extends BarMode("relative")
}
View
@@ -10,7 +10,7 @@ object Deps {
def almondScalaApi = "sh.almond" % "scala-kernel-api" % "0.1.9" cross CrossVersion.full
def argonautShapeless = setting("com.github.alexarchambault" %%% "argonaut-shapeless_6.2" % "1.2.0-M8")
def jodaTime = "joda-time" % "joda-time" % "2.9.1"
def rhino = "org.mozilla" % "rhino" % "1.7.7.1"
def rhino = "org.mozilla" % "rhino" % "1.7.10"
def shapeless = setting("com.chuusai" %%% "shapeless" % "2.3.3")
def scalacheckShapeless = setting("com.github.alexarchambault" %%% "scalacheck-shapeless_1.14" % "1.2.0-1")
def scalajsDom = setting("org.scala-js" %%% "scalajs-dom" % "0.9.6")
View
@@ -3,11 +3,9 @@ import sbt._
object WebDeps {
private val plotlyVersion = "1.24.1"
def bootstrap = "org.webjars.bower" % "bootstrap" % "3.3.6"
def jquery = "org.webjars.bower" % "jquery" % "2.2.4"
def plotlyJs = "org.webjars.bower" % "plotly.js" % plotlyVersion
def plotlyJs = "org.webjars.bower" % "plotly.js" % "1.41.3"
def prism = "org.webjars.bower" % "prism" % "1.5.0"
}
@@ -133,11 +133,15 @@ object ArgonautCodecsInternals extends ArgonautCodecsExtra {
implicit val boxMeanOtherIsEnum = IsEnum.instance[BoxMean.Labeled](_.label)
implicit val boxPointsOtherIsEnum = IsEnum.instance[BoxPoints.Labeled](_.label)
implicit val textPositionIsEnum = IsEnum.instance[TextPosition](_.label)
implicit val barTextPositionIsEnum = IsEnum.instance[BarTextPosition](_.label)
implicit val sideIsEnum = IsEnum.instance[Side](_.label)
implicit val symbolIsEnum = IsEnum.instance[Symbol](_.label)
implicit val ticksIsEnum = IsEnum.instance[Ticks](_.label)
implicit val histNormIsEnum = IsEnum.instance[HistNorm](_.label)
implicit val sizeModeIsEnum = IsEnum.instance[SizeMode](_.label)
implicit val hoverOnIsEnum = IsEnum.instance[HoverOn](_.label)
implicit val groupNormIsEnum = IsEnum.instance[GroupNorm](_.label)
implicit val histFuncIsEnum = IsEnum.instance[HistFunc](_.label)
def jsonSumDirectCodecFor(name: String): JsonSumCodec = new JsonSumCodec {
def encodeEmpty: Nothing =
@@ -201,6 +205,33 @@ object ArgonautCodecsInternals extends ArgonautCodecsExtra {
val default = JsonProductObjCodecNoEmpty()
}
implicit val encodeHoverInfo: EncodeJson[HoverInfo] =
EncodeJson.of[String].contramap(_.label)
implicit val decodeHoverInfo: DecodeJson[HoverInfo] =
DecodeJson { c =>
DecodeJson.of[String].apply(c).flatMap {
case "all" => DecodeResult.ok(HoverInfo.All)
case "skip" => DecodeResult.ok(HoverInfo.Skip)
case "none" => DecodeResult.ok(HoverInfo.None)
case combination =>
val results = combination.split('+').map {
case "x" => Right(HoverInfo.X)
case "y" => Right(HoverInfo.Y)
case "z" => Right(HoverInfo.Z)
case "text" => Right(HoverInfo.Text)
case "name" => Right(HoverInfo.Name)
case other => Left(s"Unrecognized hover info element: $other")
}
if (results.exists(_.isLeft))
DecodeResult.fail(
s"Unrecognized hover info elements: ${results.flatMap(_.left.toSeq).mkString(", ")}",
c.history
)
else
DecodeResult.ok(HoverInfo(results.flatMap(_.right.toSeq): _*))
}
}
implicit def defaultJsonProductCodecFor[T]: JsonProductCodecFor[T] =
JsonProductCodecFor(JsonProductObjCodecNoEmpty.default)
Oops, something went wrong.

0 comments on commit ad3b283

Please sign in to comment.