From 77c32ee18959711fd7a9ca8b59071fa260e1a8e2 Mon Sep 17 00:00:00 2001 From: Sven Behrens Date: Sat, 27 Apr 2024 14:54:58 +0200 Subject: [PATCH 1/7] Update to scala 2.13.14, 2.12.19 and sbt 1.10.0 --- .github/workflows/ci.yml | 2 +- project/Settings.scala | 4 ++-- project/build.properties | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index def8e57..d1a05e2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - SCALA_VERSION: ["2.12.17", "2.13.10"] + SCALA_VERSION: ["2.12.19", "2.13.14"] steps: - uses: actions/checkout@v3 - uses: coursier/cache-action@v6 diff --git a/project/Settings.scala b/project/Settings.scala index b27f125..2f413d2 100644 --- a/project/Settings.scala +++ b/project/Settings.scala @@ -86,8 +86,8 @@ object Settings { (Compile / sourceGenerators) += customSourceGenerators.taskValue ) - private val scala212 = "2.12.17" - private val scala213 = "2.13.10" + private val scala212 = "2.12.19" + private val scala213 = "2.13.14" private lazy val isAtLeastScala213 = Def.setting { import Ordering.Implicits._ diff --git a/project/build.properties b/project/build.properties index 46e43a9..081fdbb 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.8.2 +sbt.version=1.10.0 From b243d09f0c6b364391e16aca8f137393fde76140 Mon Sep 17 00:00:00 2001 From: Sven Behrens Date: Sat, 27 Apr 2024 14:55:18 +0200 Subject: [PATCH 2/7] Update sbt plugins --- project/plugins.sbt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 6b10c15..f23f16f 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,6 +1,6 @@ -addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.11") -addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.2") -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.13.0") -addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.2.0") +addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12") +addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.3") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.16.0") +addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.3.2") addSbtPlugin("org.scala-js" % "sbt-jsdependencies" % "1.0.2") -addSbtPlugin("io.get-coursier" % "sbt-shading" % "2.1.1") +addSbtPlugin("io.get-coursier" % "sbt-shading" % "2.1.4") From 2b6ce66bbcab1c41c1d7b56d74b92d0ee043dbb7 Mon Sep 17 00:00:00 2001 From: Sven Behrens Date: Sat, 27 Apr 2024 14:55:46 +0200 Subject: [PATCH 3/7] Update scala deps --- project/Deps.scala | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/project/Deps.scala b/project/Deps.scala index bd8af60..c793c9f 100644 --- a/project/Deps.scala +++ b/project/Deps.scala @@ -7,15 +7,15 @@ object Deps { import Def.setting - def almondScalaApi = "sh.almond" %% "jupyter-api" % "0.13.4" + def almondScalaApi = "sh.almond" %% "jupyter-api" % "0.13.14" def argonautShapeless = setting("com.github.alexarchambault" %%% "argonaut-shapeless_6.3" % "1.3.1") def dataClass = "io.github.alexarchambault" %% "data-class" % "0.2.6" - def jodaTime = "joda-time" % "joda-time" % "2.12.4" + def jodaTime = "joda-time" % "joda-time" % "2.12.7" def rhino = "org.mozilla" % "rhino" % "1.7.14" def shapeless = setting("com.chuusai" %%% "shapeless" % "2.3.7") def scalacheckShapeless = setting("com.github.alexarchambault" %%% "scalacheck-shapeless_1.15" % "1.3.0") - def scalajsDom = setting("org.scala-js" %%% "scalajs-dom" % "2.4.0") - def scalatags = setting("com.lihaoyi" %%% "scalatags" % "0.12.0") - def scalaTest = "org.scalatest" %% "scalatest" % "3.2.15" + def scalajsDom = setting("org.scala-js" %%% "scalajs-dom" % "2.8.0") + def scalatags = setting("com.lihaoyi" %%% "scalatags" % "0.13.1") + def scalaTest = "org.scalatest" %% "scalatest" % "3.2.18" } From d424ec996656255ab5f1ad257adefe5a147aa241 Mon Sep 17 00:00:00 2001 From: Sven Behrens Date: Sat, 27 Apr 2024 15:29:06 +0200 Subject: [PATCH 4/7] Add scalafmt and .editorconfig --- .editorconfig | 15 +++++++++++++++ .scalafmt.conf | 27 +++++++++++++++++++++++++++ project/plugins.sbt | 11 ++++++----- 3 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 .editorconfig create mode 100644 .scalafmt.conf diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..82da0b1 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +# http://editorconfig.org + +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +insert_final_newline = false +trim_trailing_whitespace = false \ No newline at end of file diff --git a/.scalafmt.conf b/.scalafmt.conf new file mode 100644 index 0000000..26c5bce --- /dev/null +++ b/.scalafmt.conf @@ -0,0 +1,27 @@ +version = "3.8.1" + +runner.dialect = scala213 + +preset = defaultWithAlign + +maxColumn = 120 + +assumeStandardLibraryStripMargin = true + +align { + arrowEnumeratorGenerator = true +} + +newlines { + penalizeSingleSelectMultiArgList = true +} + +rewrite { + rules = [Imports, PreferCurlyFors, RedundantParens] + imports.sort = scalastyle +} + +docstrings.wrap=no + +// only format files tracked by git +project.git = true diff --git a/project/plugins.sbt b/project/plugins.sbt index f23f16f..065728c 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,6 +1,7 @@ -addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12") -addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.3") -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.16.0") +addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12") +addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.3") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.16.0") addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.3.2") -addSbtPlugin("org.scala-js" % "sbt-jsdependencies" % "1.0.2") -addSbtPlugin("io.get-coursier" % "sbt-shading" % "2.1.4") +addSbtPlugin("org.scala-js" % "sbt-jsdependencies" % "1.0.2") +addSbtPlugin("io.get-coursier" % "sbt-shading" % "2.1.4") +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.0") From f3dd28cca4ea661c2449e6cafa109913858ff589 Mon Sep 17 00:00:00 2001 From: Sven Behrens Date: Mon, 6 May 2024 14:09:18 +0200 Subject: [PATCH 5/7] Fix compiler warnings --- .../src/main/scala/plotly/Enumerate.scala | 2 +- .../internals/ArgonautCodecsInternals.scala | 214 +++++++++--------- 2 files changed, 106 insertions(+), 110 deletions(-) diff --git a/render/shared/src/main/scala/plotly/Enumerate.scala b/render/shared/src/main/scala/plotly/Enumerate.scala index edb0cb0..d701c7a 100644 --- a/render/shared/src/main/scala/plotly/Enumerate.scala +++ b/render/shared/src/main/scala/plotly/Enumerate.scala @@ -7,7 +7,7 @@ sealed abstract class Enumerate[T] { } object Enumerate { - def apply[T](implicit enum: Enumerate[T]): Enumerate[T] = enum + def apply[T](implicit enumerate: Enumerate[T]): Enumerate[T] = enumerate private def instance[T](values: => Seq[T]): Enumerate[T] = new Enumerate[T] { diff --git a/render/shared/src/main/scala/plotly/internals/ArgonautCodecsInternals.scala b/render/shared/src/main/scala/plotly/internals/ArgonautCodecsInternals.scala index 6f1e270..af2ebc6 100755 --- a/render/shared/src/main/scala/plotly/internals/ArgonautCodecsInternals.scala +++ b/render/shared/src/main/scala/plotly/internals/ArgonautCodecsInternals.scala @@ -17,49 +17,47 @@ object ArgonautCodecsInternals extends ArgonautCodecsExtra { sealed abstract class IsWrapper[W] - implicit def isWrapperEncode[W, L <: HList, T] - (implicit - ev: IsWrapper[W], - gen: Generic.Aux[W, L], - isHCons: ops.hlist.IsHCons.Aux[L, T, HNil], - underlying: EncodeJson[T] - ): EncodeJson[W] = + implicit def isWrapperEncode[W, L <: HList, T](implicit + ev: IsWrapper[W], + gen: Generic.Aux[W, L], + isHCons: ops.hlist.IsHCons.Aux[L, T, HNil], + underlying: EncodeJson[T] + ): EncodeJson[W] = EncodeJson { w => val t = isHCons.head(gen.to(w)) t.asJson } - implicit def isWrapperDecode[W, L <: HList, T] - (implicit - ev: IsWrapper[W], - gen: Generic.Aux[W, L], - isHCons: ops.hlist.IsHCons.Aux[L, T, HNil], - underlying: DecodeJson[T] - ): DecodeJson[W] = + implicit def isWrapperDecode[W, L <: HList, T](implicit + ev: IsWrapper[W], + gen: Generic.Aux[W, L], + isHCons: ops.hlist.IsHCons.Aux[L, T, HNil], + underlying: DecodeJson[T] + ): DecodeJson[W] = DecodeJson { c => - c.as[T].map(t => - gen.from((t :: HNil).asInstanceOf[L]) // FIXME - ) + c.as[T] + .map(t => gen.from((t :: HNil).asInstanceOf[L]) // FIXME + ) } - implicit val boxMeanBoolIsWrapper: IsWrapper[BoxMean.Bool] = null - implicit val boxPointsBoolIsWrapper: IsWrapper[BoxPoints.Bool] = null - implicit val sequenceDoublesIsWrapper: IsWrapper[Sequence.Doubles] = null + 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 sequenceNestedIntsIsWrapper: IsWrapper[Sequence.NestedInts] = null - implicit val sequenceStringsIsWrapper: IsWrapper[Sequence.Strings] = null - implicit val sequenceDatetimesIsWrapper: IsWrapper[Sequence.DateTimes] = null - implicit val rangeDoublesIsWrapper: IsWrapper[Range.Doubles] = null - implicit val rangeDatetimesIsWrapper: IsWrapper[Range.DateTimes] = null - implicit val doubleElementIsWrapper: IsWrapper[Element.DoubleElement] = null - implicit val stringElementIsWrapper: IsWrapper[Element.StringElement] = null - implicit def oneOrSeqOneIsWrapper[T]: IsWrapper[OneOrSeq.One[T]] = null - implicit def oneOrSeqSequenceIsWrapper[T]: IsWrapper[OneOrSeq.Sequence[T]] = null + implicit val sequenceNestedIntsIsWrapper: IsWrapper[Sequence.NestedInts] = null + implicit val sequenceStringsIsWrapper: IsWrapper[Sequence.Strings] = null + implicit val sequenceDatetimesIsWrapper: IsWrapper[Sequence.DateTimes] = null + implicit val rangeDoublesIsWrapper: IsWrapper[Range.Doubles] = null + implicit val rangeDatetimesIsWrapper: IsWrapper[Range.DateTimes] = null + implicit val doubleElementIsWrapper: IsWrapper[Element.DoubleElement] = null + implicit val stringElementIsWrapper: IsWrapper[Element.StringElement] = null + implicit def oneOrSeqOneIsWrapper[T]: IsWrapper[OneOrSeq.One[T]] = null + implicit def oneOrSeqSequenceIsWrapper[T]: IsWrapper[OneOrSeq.Sequence[T]] = null def flagEncoder[T, F](flags: T => Set[F], label: F => String): EncodeJson[T] = EncodeJson { t => val s = flags(t).toSeq match { - case Seq() => "none" + case Seq() => "none" case nonEmpty => nonEmpty.map(label).mkString("+") } @@ -73,12 +71,14 @@ object ArgonautCodecsInternals extends ArgonautCodecsExtra { if (s == "none") DecodeResult.ok(Set.empty[F]) else - s.split('+').foldLeft[DecodeResult[Set[F]]](DecodeResult.ok(Set.empty[F])) { - case (acc, f) => - for { - acc0 <- acc - f0 <- map.get(f).fold[DecodeResult[F]](DecodeResult.fail(s"Unrecognized $type0: $f", c.history))(DecodeResult.ok) - } yield acc0 + f0 + s.split('+').foldLeft[DecodeResult[Set[F]]](DecodeResult.ok(Set.empty[F])) { case (acc, f) => + for { + acc0 <- acc + f0 <- + map + .get(f) + .fold[DecodeResult[F]](DecodeResult.fail(s"Unrecognized $type0: $f", c.history))(DecodeResult.ok) + } yield acc0 + f0 } flags.map(build) @@ -94,63 +94,62 @@ object ArgonautCodecsInternals extends ArgonautCodecsExtra { def instance[T](f: T => String): IsEnum[T] = new IsEnum[T] { - def label(t: T) = f(t) + def label(t: T): String = f(t) } } implicit def isEnumEncoder[T: IsEnum]: EncodeJson[T] = EncodeJson.of[String].contramap(IsEnum[T].label) - implicit def isEnumDecoder[T] - (implicit - isEnum: IsEnum[T], - enum: Enumerate[T], - typeable: Typeable[T] - ): DecodeJson[T] = + implicit def isEnumDecoder[T](implicit + isEnum: IsEnum[T], + enumerate: Enumerate[T], + typeable: Typeable[T] + ): DecodeJson[T] = DecodeJson { val underlying = DecodeJson.of[String] - val map = enum().map(e => isEnum.label(e) -> e).toMap - val name = typeable.describe // TODO split in words + val map = enumerate().map(e => isEnum.label(e) -> e).toMap + val name = typeable.describe // TODO split in words c => underlying(c).flatMap { s => map.get(s) match { - case None => DecodeResult.fail(s"Unrecognized $name: '$s'", c.history) + case None => DecodeResult.fail(s"Unrecognized $name: '$s'", c.history) case Some(m) => DecodeResult.ok(m) } } } - implicit val anchorIsEnum = IsEnum.instance[Anchor](_.label) - implicit val refIsEnum = IsEnum.instance[Ref](_.label) - implicit val axisAnchorIsEnum = IsEnum.instance[AxisAnchor](_.label) - implicit val axisReferenceIsEnum = IsEnum.instance[AxisReference](_.label) - implicit val axisTypeIsEnum = IsEnum.instance[AxisType](_.label) - implicit val barModeIsEnum = IsEnum.instance[BarMode](_.label) - implicit val boxModeIsEnum = IsEnum.instance[BoxMode](_.label) - implicit val dashIsEnum = IsEnum.instance[Dash](_.label) - implicit val fillIsEnum = IsEnum.instance[Fill](_.label) - implicit val hoverModeIsEnum = IsEnum.instance[HoverMode](_.label) - implicit val lineShapeIsEnum = IsEnum.instance[LineShape](_.label) - implicit val orientationIsEnum = IsEnum.instance[Orientation](_.label) - implicit val traceOrderIsEnum = IsEnum.instance[TraceOrder](_.label) - 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 anchorIsEnum = IsEnum.instance[Anchor](_.label) + implicit val refIsEnum = IsEnum.instance[Ref](_.label) + implicit val axisAnchorIsEnum = IsEnum.instance[AxisAnchor](_.label) + implicit val axisReferenceIsEnum = IsEnum.instance[AxisReference](_.label) + implicit val axisTypeIsEnum = IsEnum.instance[AxisType](_.label) + implicit val barModeIsEnum = IsEnum.instance[BarMode](_.label) + implicit val boxModeIsEnum = IsEnum.instance[BoxMode](_.label) + implicit val dashIsEnum = IsEnum.instance[Dash](_.label) + implicit val fillIsEnum = IsEnum.instance[Fill](_.label) + implicit val hoverModeIsEnum = IsEnum.instance[HoverMode](_.label) + implicit val lineShapeIsEnum = IsEnum.instance[LineShape](_.label) + implicit val orientationIsEnum = IsEnum.instance[Orientation](_.label) + implicit val traceOrderIsEnum = IsEnum.instance[TraceOrder](_.label) + 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) - implicit val tickModeIsEnum = IsEnum.instance[TickMode](_.mode) - implicit val patternIsEnum = IsEnum.instance[Pattern](_.label) - implicit val rowOrderIsEnum = IsEnum.instance[RowOrder](_.label) - implicit val alignmentIsEnum = IsEnum.instance[Alignment](_.label) - implicit val colorModelIsEnum = IsEnum.instance[ColorModel](_.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) + implicit val tickModeIsEnum = IsEnum.instance[TickMode](_.mode) + implicit val patternIsEnum = IsEnum.instance[Pattern](_.label) + implicit val rowOrderIsEnum = IsEnum.instance[RowOrder](_.label) + implicit val alignmentIsEnum = IsEnum.instance[Alignment](_.label) + implicit val colorModelIsEnum = IsEnum.instance[ColorModel](_.label) def jsonSumDirectCodecFor(name: String): JsonSumCodec = new JsonSumCodec { def encodeEmpty: Nothing = @@ -158,12 +157,12 @@ object ArgonautCodecsInternals extends ArgonautCodecsExtra { def encodeField(fieldOrObj: Either[Json, (String, Json)]): Json = fieldOrObj match { - case Left(other) => other + case Left(other) => other case Right((_, content)) => content } def decodeEmpty(cursor: HCursor): DecodeResult[Nothing] = - // FIXME Sometimes reports the wrong error (in case of two nested sum types) + // FIXME Sometimes reports the wrong error (in case of two nested sum types) DecodeResult.fail(s"unrecognized $name", cursor.history) def decodeField[A](name: String, cursor: HCursor, decode: DecodeJson[A]): DecodeResult[Either[ACursor, A]] = @@ -175,7 +174,7 @@ object ArgonautCodecsInternals extends ArgonautCodecsExtra { } case class JsonProductObjCodecNoEmpty( - toJsonName: String => String = identity + toJsonName: String => String = identity ) extends JsonProductCodec { private val underlying = JsonProductCodec.adapt(toJsonName) @@ -194,7 +193,12 @@ object ArgonautCodecsInternals extends ArgonautCodecsExtra { cursor.history ) - def decodeField[A](name: String, cursor: HCursor, decode: DecodeJson[A], default: Option[A]): DecodeResult[(A, ACursor)] = { + def decodeField[A]( + name: String, + cursor: HCursor, + decode: DecodeJson[A], + default: Option[A] + ): DecodeResult[(A, ACursor)] = { val c = cursor.downField(toJsonName(name)) def result = c.as(decode).map((_, if (c.succeeded) c.delete else ACursor.ok(cursor))) @@ -219,18 +223,18 @@ object ArgonautCodecsInternals extends ArgonautCodecsExtra { implicit val decodeHoverInfo: DecodeJson[HoverInfo] = DecodeJson { c => DecodeJson.of[String].apply(c).flatMap { - case "all" => DecodeResult.ok(HoverInfo.All) + 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 "x" => Right(HoverInfo.X) + case "y" => Right(HoverInfo.Y) + case "z" => Right(HoverInfo.Z) case "color" => Right(HoverInfo.Color) - case "text" => Right(HoverInfo.Text) - case "name" => Right(HoverInfo.Name) - case other => Left(s"Unrecognized hover info element: $other") + 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( @@ -242,7 +246,6 @@ object ArgonautCodecsInternals extends ArgonautCodecsExtra { } } - implicit def defaultJsonProductCodecFor[T]: JsonProductCodecFor[T] = JsonProductCodecFor(JsonProductObjCodecNoEmpty.default) @@ -256,9 +259,9 @@ object ArgonautCodecsInternals extends ArgonautCodecsExtra { s.stripPrefix("rgba(").stripSuffix(")").split(',').map(_.trim) match { case Array(rStr, gStr, bStr, alphaStr) => val res = for { - r <- Try(rStr.toInt).toOption - g <- Try(gStr.toInt).toOption - b <- Try(bStr.toInt).toOption + r <- Try(rStr.toInt).toOption + g <- Try(gStr.toInt).toOption + b <- Try(bStr.toInt).toOption alpha <- Try(alphaStr.toDouble).toOption } yield DecodeResult.ok(Color.RGBA(r, g, b, alpha)) @@ -279,15 +282,14 @@ object ArgonautCodecsInternals extends ArgonautCodecsExtra { implicit val decodeStringColor: DecodeJson[Color.StringColor] = DecodeJson { val underlying = DecodeJson.of[String] - val map = Color.StringColor.colors - .toVector + val map = Color.StringColor.colors.toVector .map(c => c -> Color.StringColor(c)) .toMap c => underlying(c).flatMap { s => map.get(s) match { - case None => DecodeResult.fail(s"Unrecognized color: '$s'", c.history) + case None => DecodeResult.fail(s"Unrecognized color: '$s'", c.history) case Some(m) => DecodeResult.ok(m) } } @@ -340,25 +342,21 @@ object ArgonautCodecsInternals extends ArgonautCodecsExtra { DecodeResult.fail(s"Unrecognized RGB color: $other", c.history) } - asString - .toOption + asString.toOption .orElse(asInt.toOption) .fold(asHexa)(DecodeResult.ok) } private def decodeNum(s: String) = { - val intOpt = Try(s.toInt) - .toOption + val intOpt = Try(s.toInt).toOption - val fromDouble = Try(s.toDouble) - .toOption + val fromDouble = Try(s.toDouble).toOption .map(_.toInt) def fromPct = if (s.endsWith("%")) - Try(s.stripSuffix("%").trim.toDouble) - .toOption + Try(s.stripSuffix("%").trim.toDouble).toOption .map(v => (256 * v).toInt) else None @@ -457,12 +455,12 @@ object ArgonautCodecsInternals extends ArgonautCodecsExtra { implicit val encodeError: EncodeJson[Error] = EncodeJson { error => val json = error match { - case data: Error.Data => data.asJson - case pct: Error.Percent => pct.asJson + case data: Error.Data => data.asJson + case pct: Error.Percent => pct.asJson case cst: Error.Constant => cst.asJson } - json.obj.fold(json)(o => Json.jObject(("type" -> error.`type`.asJson) +: o)) + json.obj.fold(json)(o => Json.jObject(("type" -> error.`type`.asJson) +: o)) } implicit val decodeError: DecodeJson[Error] = @@ -488,15 +486,13 @@ object ArgonautCodecsInternals extends ArgonautCodecsExtra { implicit val jsonSumCodecForColor: JsonSumCodecFor[Color] = JsonSumCodecFor(jsonSumDirectCodecFor("color")) - case class WrappedFont(font: Font) - val derivedFontDecoder = MkDecodeJson[Font].decodeJson + val derivedFontDecoder = MkDecodeJson[Font].decodeJson lazy val wrappedFontDecoder = DecodeJson.of[WrappedFont].map(_.font) implicit lazy val decodeFont: DecodeJson[Font] = - DecodeJson { - c => - wrappedFontDecoder(c).toOption.fold(derivedFontDecoder(c))(DecodeResult.ok) + DecodeJson { c => + wrappedFontDecoder(c).toOption.fold(derivedFontDecoder(c))(DecodeResult.ok) } implicit val jsonCodecForTrace = JsonSumCodecFor[Trace]( From 0ad886c35bdf9c8ad2bfb0501070b8b2ce810710 Mon Sep 17 00:00:00 2001 From: Sven Behrens Date: Mon, 6 May 2024 14:10:06 +0200 Subject: [PATCH 6/7] Format code with scalafmt 3.8.1 --- almond/src/main/scala/plotly/Almond.scala | 220 ++++----- build.sbt | 49 +- .../element/PlotlyJavaTimeConversions.scala | 5 +- .../shared/src/main/scala/plotly/Config.scala | 18 +- core/shared/src/main/scala/plotly/Range.scala | 2 +- .../src/main/scala/plotly/Sequence.scala | 8 +- core/shared/src/main/scala/plotly/Trace.scala | 422 +++++++++--------- .../main/scala/plotly/element/Alignment.scala | 4 +- .../main/scala/plotly/element/Anchor.scala | 6 +- .../scala/plotly/element/AxisAnchor.scala | 4 +- .../scala/plotly/element/AxisReference.scala | 4 +- .../main/scala/plotly/element/AxisType.scala | 9 +- .../src/main/scala/plotly/element/Bins.scala | 6 +- .../main/scala/plotly/element/BoxMean.scala | 4 +- .../main/scala/plotly/element/BoxPoints.scala | 8 +- .../scala/plotly/element/ColorModel.scala | 8 +- .../scala/plotly/element/ColorScale.scala | 4 +- .../src/main/scala/plotly/element/Error.scala | 54 +-- .../main/scala/plotly/element/GroupNorm.scala | 2 +- .../main/scala/plotly/element/HistFunc.scala | 8 +- .../main/scala/plotly/element/HistNorm.scala | 8 +- .../main/scala/plotly/element/HoverInfo.scala | 14 +- .../scala/plotly/element/HoverLabel.scala | 12 +- .../scala/plotly/element/HoverLabelFont.scala | 6 +- .../main/scala/plotly/element/HoverOn.scala | 4 +- .../src/main/scala/plotly/element/Line.scala | 28 +- .../main/scala/plotly/element/LineShape.scala | 8 +- .../scala/plotly/element/LocalDateTime.scala | 15 +- .../main/scala/plotly/element/Marker.scala | 38 +- .../main/scala/plotly/element/OneOrSeq.scala | 2 +- .../scala/plotly/element/ScatterMode.scala | 6 +- .../src/main/scala/plotly/element/Side.scala | 6 +- .../main/scala/plotly/element/SizeMode.scala | 2 +- .../main/scala/plotly/element/Symbol.scala | 14 +- .../main/scala/plotly/element/TickMode.scala | 6 +- .../src/main/scala/plotly/element/Ticks.scala | 4 +- .../main/scala/plotly/layout/Annotation.scala | 40 +- .../src/main/scala/plotly/layout/Axis.scala | 190 ++++---- .../main/scala/plotly/layout/BarMode.scala | 8 +- .../src/main/scala/plotly/layout/Font.scala | 12 +- .../src/main/scala/plotly/layout/Grid.scala | 10 +- .../src/main/scala/plotly/layout/Layout.scala | 114 ++--- .../src/main/scala/plotly/layout/Legend.scala | 46 +- .../src/main/scala/plotly/layout/Margin.scala | 26 +- .../main/scala/plotly/layout/Pattern.scala | 2 +- .../scala/plotly/layout/RangeSlider.scala | 2 +- .../src/main/scala/plotly/layout/Ref.scala | 2 +- .../src/main/scala/plotly/layout/Scene.scala | 14 +- .../src/main/scala/plotly/layout/Shape.scala | 20 +- demo/src/main/scala/plotly/demo/Demo.scala | 49 +- .../demo/area/BasicOverlaidAreaChart.scala | 4 +- .../demo/bar/BarChartWithDirectLabels.scala | 21 +- .../scala/plotly/demo/bar/BasicBarChart.scala | 4 +- .../bar/CustomizingIndividualBarColors.scala | 20 +- .../plotly/demo/bar/GroupedBarChart.scala | 4 +- .../plotly/demo/bar/WaterfallBarChart.scala | 39 +- .../bubblecharts/HoverOnTextBubbleChart.scala | 23 +- .../demo/heatmaps/AnnotatedHeatmap.scala | 18 +- .../plotly/demo/heatmaps/BasicHeatmap.scala | 6 +- .../heatmaps/CategoricalAxisHeatmap.scala | 18 +- .../heatmaps/CustomColorScaleHeatmap.scala | 40 +- .../BasicHorizontalBarChart.scala | 4 +- .../horizontalbarcharts/ColoredBarChart.scala | 4 +- .../plotly/demo/timeseries/TimeSeries.scala | 4 +- project/Mima.scala | 3 +- project/Settings.scala | 24 +- project/WebDeps.scala | 7 +- render/js/src/main/scala/plotly/Plotly.scala | 104 ++--- render/jvm/src/main/scala/plotly/Plotly.scala | 172 +++---- .../scala/plotly/internals/Properties.scala | 10 +- .../src/main/scala/plotly/Enumerate.scala | 29 +- .../plotly/internals/BetterPrinter.scala | 151 ++++--- tests/src/test/scala/plotly/FieldTests.scala | 3 +- .../src/test/scala/plotly/SequenceTests.scala | 4 +- .../scala/plotly/doc/DocumentationTests.scala | 98 ++-- .../test/scala/plotly/doc/SchemaTests.scala | 37 +- .../plotly/element/LocalDateTimeTests.scala | 10 +- 77 files changed, 1222 insertions(+), 1192 deletions(-) diff --git a/almond/src/main/scala/plotly/Almond.scala b/almond/src/main/scala/plotly/Almond.scala index e38b0b1..41e7bb9 100644 --- a/almond/src/main/scala/plotly/Almond.scala +++ b/almond/src/main/scala/plotly/Almond.scala @@ -20,25 +20,25 @@ object Almond { val requireInit = if (offline) - s"""define('plotly', function(require, exports, module) { - | ${Plotly.plotlyMinJs} - |}); + s"""define('plotly', function(require, exports, module) { + | ${Plotly.plotlyMinJs} + |}); """.stripMargin else s"""require.config({ - | paths: { - | d3: 'https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.17/d3.min', - | plotly: 'https://cdn.plot.ly/plotly-${Plotly.plotlyVersion}.min', - | jquery: 'https://code.jquery.com/jquery-3.3.1.min' - | }, - | - | shim: { - | plotly: { - | deps: ['d3', 'jquery'], - | exports: 'plotly' - | } - | } - |}); + | paths: { + | d3: 'https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.17/d3.min', + | plotly: 'https://cdn.plot.ly/plotly-${Plotly.plotlyVersion}.min', + | jquery: 'https://code.jquery.com/jquery-3.3.1.min' + | }, + | + | shim: { + | plotly: { + | deps: ['d3', 'jquery'], + | exports: 'plotly' + | } + | } + |}); """.stripMargin val html = s""" @@ -57,12 +57,12 @@ object Almond { } def plotJs( - data: Seq[Trace], - layout: Layout, - config: Config, - div: String = "" + data: Seq[Trace], + layout: Layout, + config: Config, + div: String = "" )(implicit - publish: OutputHandler + publish: OutputHandler ): String = { val (div0, divPart) = @@ -73,12 +73,12 @@ object Almond { (div, "") val baseJs = Plotly.jsSnippet(div0, data, layout, config) - val json = Plotly.jsonSnippet(data, layout, config) + val json = Plotly.jsonSnippet(data, layout, config) val js = - s"""require(['plotly'], function(Plotly) { - | $baseJs - |}); + s"""require(['plotly'], function(Plotly) { + | $baseJs + |}); """.stripMargin val data0 = DisplayData( @@ -100,12 +100,12 @@ object Almond { almond.display.UpdatableDisplay.generateDiv("plot-") def plot( - data: Seq[Trace], - layout: Layout = Layout(), - config: Config = Config(), - div: String = "" + data: Seq[Trace], + layout: Layout = Layout(), + config: Config = Config(), + div: String = "" )(implicit - publish: OutputHandler + publish: OutputHandler ): String = { if (!Internal.initialized) @@ -123,39 +123,39 @@ object Almond { @deprecated("Create a Layout and / or a Config, and call one of the other plot methods instead", "0.8.0") def plot( - title: String = null, - legend: Legend = null, - width: JInt = null, - height: JInt = null, - showlegend: JBoolean = null, - xaxis: Axis = null, - yaxis: Axis = null, - xaxis1: Axis = null, - xaxis2: Axis = null, - xaxis3: Axis = null, - xaxis4: Axis = null, - yaxis1: Axis = null, - yaxis2: Axis = null, - yaxis3: Axis = null, - yaxis4: Axis = null, - barmode: BarMode = null, - autosize: JBoolean = null, - margin: Margin = null, - annotations: Seq[Annotation] = null, - plot_bgcolor: Color = null, - paper_bgcolor: Color = null, - font: Font = null, - bargap: JDouble = null, - bargroupgap: JDouble = null, - hovermode: HoverMode = null, - boxmode: BoxMode = null, - editable: JBoolean = null, - responsive: JBoolean = null, - showEditInChartStudio: JBoolean = null, - plotlyServerURL: String = null, - div: String = "" + title: String = null, + legend: Legend = null, + width: JInt = null, + height: JInt = null, + showlegend: JBoolean = null, + xaxis: Axis = null, + yaxis: Axis = null, + xaxis1: Axis = null, + xaxis2: Axis = null, + xaxis3: Axis = null, + xaxis4: Axis = null, + yaxis1: Axis = null, + yaxis2: Axis = null, + yaxis3: Axis = null, + yaxis4: Axis = null, + barmode: BarMode = null, + autosize: JBoolean = null, + margin: Margin = null, + annotations: Seq[Annotation] = null, + plot_bgcolor: Color = null, + paper_bgcolor: Color = null, + font: Font = null, + bargap: JDouble = null, + bargroupgap: JDouble = null, + hovermode: HoverMode = null, + boxmode: BoxMode = null, + editable: JBoolean = null, + responsive: JBoolean = null, + showEditInChartStudio: JBoolean = null, + plotlyServerURL: String = null, + div: String = "" )(implicit - publish: OutputHandler + publish: OutputHandler ): String = plot( Layout( @@ -195,77 +195,77 @@ object Almond { ) def plot( - layout: Layout, - config: Config, - div: String + layout: Layout, + config: Config, + div: String )(implicit - publish: OutputHandler + publish: OutputHandler ): String = Almond.plot(Seq(data), layout, config, div = div) def plot()(implicit - publish: OutputHandler + publish: OutputHandler ): String = plot(Layout(), Config(), "") def plot( - layout: Layout + layout: Layout )(implicit - publish: OutputHandler + publish: OutputHandler ): String = plot(layout, Config(), "") def plot( - config: Config + config: Config )(implicit - publish: OutputHandler + publish: OutputHandler ): String = plot(Layout(), config, "") def plot( - layout: Layout, - config: Config + layout: Layout, + config: Config )(implicit - publish: OutputHandler + publish: OutputHandler ): String = plot(layout, config, "") } implicit class DataSeqOps(val data: Seq[Trace]) extends AnyVal { def plot( - title: String = null, - legend: Legend = null, - width: JInt = null, - height: JInt = null, - showlegend: JBoolean = null, - xaxis: Axis = null, - yaxis: Axis = null, - xaxis1: Axis = null, - xaxis2: Axis = null, - xaxis3: Axis = null, - xaxis4: Axis = null, - yaxis1: Axis = null, - yaxis2: Axis = null, - yaxis3: Axis = null, - yaxis4: Axis = null, - barmode: BarMode = null, - autosize: JBoolean = null, - margin: Margin = null, - annotations: Seq[Annotation] = null, - plot_bgcolor: Color = null, - paper_bgcolor: Color = null, - font: Font = null, - bargap: JDouble = null, - bargroupgap: JDouble = null, - hovermode: HoverMode = null, - boxmode: BoxMode = null, - editable: JBoolean = null, - responsive: JBoolean = null, - showEditInChartStudio: JBoolean = null, - plotlyServerURL: String = null, - div: String = "" + title: String = null, + legend: Legend = null, + width: JInt = null, + height: JInt = null, + showlegend: JBoolean = null, + xaxis: Axis = null, + yaxis: Axis = null, + xaxis1: Axis = null, + xaxis2: Axis = null, + xaxis3: Axis = null, + xaxis4: Axis = null, + yaxis1: Axis = null, + yaxis2: Axis = null, + yaxis3: Axis = null, + yaxis4: Axis = null, + barmode: BarMode = null, + autosize: JBoolean = null, + margin: Margin = null, + annotations: Seq[Annotation] = null, + plot_bgcolor: Color = null, + paper_bgcolor: Color = null, + font: Font = null, + bargap: JDouble = null, + bargroupgap: JDouble = null, + hovermode: HoverMode = null, + boxmode: BoxMode = null, + editable: JBoolean = null, + responsive: JBoolean = null, + showEditInChartStudio: JBoolean = null, + plotlyServerURL: String = null, + div: String = "" )(implicit - publish: OutputHandler + publish: OutputHandler ): String = plot( Layout( @@ -305,11 +305,11 @@ object Almond { ) def plot( - layout: Layout, - config: Config, - div: String + layout: Layout, + config: Config, + div: String )(implicit - publish: OutputHandler + publish: OutputHandler ): String = Almond.plot(data, layout, config, div = div) } diff --git a/build.sbt b/build.sbt index da55e42..e5e34c5 100644 --- a/build.sbt +++ b/build.sbt @@ -1,4 +1,3 @@ - import java.nio.charset.StandardCharsets import java.nio.file.Files @@ -6,20 +5,21 @@ import Settings._ import sbtcrossproject.CrossPlugin.autoImport.crossProject - -inThisBuild(List( - organization := "org.plotly-scala", - homepage := Some(url("https://github.com/alexarchambault/plotly-scala")), - licenses := Seq("LGPL 3.0" -> url("http://opensource.org/licenses/LGPL-3.0")), - developers := List( - Developer( - "alexarchambault", - "Alexandre Archambault", - "", - url("https://github.com/alexarchambault") +inThisBuild( + List( + organization := "org.plotly-scala", + homepage := Some(url("https://github.com/alexarchambault/plotly-scala")), + licenses := Seq("LGPL 3.0" -> url("http://opensource.org/licenses/LGPL-3.0")), + developers := List( + Developer( + "alexarchambault", + "Alexandre Archambault", + "", + url("https://github.com/alexarchambault") + ) ) ) -)) +) val previousVersions = Set.empty[String] lazy val mimaSettings = Def.settings( @@ -38,7 +38,7 @@ lazy val core = crossProject(JVMPlatform, JSPlatform) ) lazy val coreJvm = core.jvm -lazy val coreJs = core.js +lazy val coreJs = core.js lazy val `joda-time` = project .dependsOn(coreJvm) @@ -63,7 +63,7 @@ lazy val render = crossProject(JVMPlatform, JSPlatform) Mima.renderFilters, shadedModules += Deps.argonautShapeless.value.module, shadingRules ++= { - val shadeUnder = "plotly.internals.shaded" + val shadeUnder = "plotly.internals.shaded" val shadeNamespaces = Seq("argonaut", "macrocompat", "shapeless") for (ns <- shadeNamespaces) yield ShadingRule.moveUnder(ns, shadeUnder), @@ -89,15 +89,14 @@ lazy val render = crossProject(JVMPlatform, JSPlatform) val props = Seq( "plotly-js-version" -> WebDeps.Versions.plotlyJs, - "version" -> ver, - "commit-hash" -> Seq("git", "rev-parse", "HEAD").!!.trim + "version" -> ver, + "commit-hash" -> Seq("git", "rev-parse", "HEAD").!!.trim ) val b = props - .map { - case (k, v) => - assert(!v.contains("\n"), s"Invalid ${"\\n"} character in property $k") - s"$k=$v" + .map { case (k, v) => + assert(!v.contains("\n"), s"Invalid ${"\\n"} character in property $k") + s"$k=$v" } .mkString("\n") .getBytes(StandardCharsets.UTF_8) @@ -125,7 +124,7 @@ lazy val render = crossProject(JVMPlatform, JSPlatform) ) lazy val renderJvm = render.jvm -lazy val renderJs = render.js +lazy val renderJs = render.js lazy val demo = project .enablePlugins(JSDependenciesPlugin, ScalaJSPlugin) @@ -135,7 +134,7 @@ lazy val demo = project shared, (publish / skip) := true, plotlyPrefix, - (Test / test) := {}, + (Test / test) := {}, (Test / testOnly) := {}, libraryDependencies += Deps.scalatags.value, jsDependencies ++= Seq( @@ -185,7 +184,7 @@ lazy val tests = project fetchTestData, libraryDependencies ++= Seq( Deps.scalaTest % "test", - Deps.rhino % "test" + Deps.rhino % "test" ) ) @@ -199,5 +198,5 @@ lazy val almond = project ) crossScalaVersions := Nil -(publish / skip) := true +(publish / skip) := true disablePlugins(MimaPlugin) diff --git a/core/jvm/src/main/scala/plotly/element/PlotlyJavaTimeConversions.scala b/core/jvm/src/main/scala/plotly/element/PlotlyJavaTimeConversions.scala index a2e9dcb..bf0d166 100644 --- a/core/jvm/src/main/scala/plotly/element/PlotlyJavaTimeConversions.scala +++ b/core/jvm/src/main/scala/plotly/element/PlotlyJavaTimeConversions.scala @@ -14,7 +14,7 @@ trait PlotlyJavaTimeConversions { javaLocalDateTime.getDayOfMonth, javaLocalDateTime.getHour, javaLocalDateTime.getMinute, - javaLocalDateTime.getSecond, + javaLocalDateTime.getSecond ) implicit def fromJavaInstant(javaInstant: Instant): PlotlyLocalDateTime = @@ -23,8 +23,7 @@ trait PlotlyJavaTimeConversions { implicit def fromJavaLocalDate(javaLocalDate: LocalDate): PlotlyLocalDateTime = fromJavaLocalDateTime(javaLocalDate.atStartOfDay) - /** - * Implicit conversions in this object convert to `plotly.element.LocalDateTime` by simply dropping timezone/offset + /** Implicit conversions in this object convert to `plotly.element.LocalDateTime` by simply dropping timezone/offset * information. This can lead to unexpected behaviour, particularly for datasets with varying offsets and timezones. * It will generally be safer to convert your data to `java.time.LocalDateTime` in the appropriate timezone/offset, * and then use the `PlotlyJavaTimeConversions.fromJavaLocalDateTime` implicit conversion. diff --git a/core/shared/src/main/scala/plotly/Config.scala b/core/shared/src/main/scala/plotly/Config.scala index 35b135d..a886516 100755 --- a/core/shared/src/main/scala/plotly/Config.scala +++ b/core/shared/src/main/scala/plotly/Config.scala @@ -1,22 +1,22 @@ package plotly -import java.lang.{ Boolean => JBoolean } +import java.lang.{Boolean => JBoolean} import dataclass.data @data(optionSetters = true) class Config( - editable: Option[Boolean] = None, - responsive: Option[Boolean] = None, - showEditInChartStudio: Option[Boolean] = None, - plotlyServerURL: Option[String] = None + editable: Option[Boolean] = None, + responsive: Option[Boolean] = None, + showEditInChartStudio: Option[Boolean] = None, + plotlyServerURL: Option[String] = None ) object Config { @deprecated("Use Config() and chain-call .with* methods on it instead", "0.8.0") def apply( - editable: JBoolean = null, - responsive: JBoolean = null, - showEditInChartStudio: JBoolean = null, - plotlyServerURL: String = null + editable: JBoolean = null, + responsive: JBoolean = null, + showEditInChartStudio: JBoolean = null, + plotlyServerURL: String = null ): Config = new Config( Option(editable), diff --git a/core/shared/src/main/scala/plotly/Range.scala b/core/shared/src/main/scala/plotly/Range.scala index eabe734..c4221cc 100644 --- a/core/shared/src/main/scala/plotly/Range.scala +++ b/core/shared/src/main/scala/plotly/Range.scala @@ -7,7 +7,7 @@ import scala.language.implicitConversions sealed abstract class Range extends Product with Serializable object Range { - final case class Doubles(range: (Double, Double)) extends Range + final case class Doubles(range: (Double, Double)) extends Range final case class DateTimes(range: (LocalDateTime, LocalDateTime)) extends Range implicit def fromDoubleTuple(t: (Double, Double)): Range = diff --git a/core/shared/src/main/scala/plotly/Sequence.scala b/core/shared/src/main/scala/plotly/Sequence.scala index c4dd3c8..f40077f 100755 --- a/core/shared/src/main/scala/plotly/Sequence.scala +++ b/core/shared/src/main/scala/plotly/Sequence.scala @@ -7,11 +7,11 @@ import scala.language.implicitConversions sealed abstract class Sequence extends Product with Serializable object Sequence extends MutableSequenceImplicitConversions { - final case class Doubles(seq: Seq[Double]) extends Sequence + final case class Doubles(seq: Seq[Double]) extends Sequence final case class NestedDoubles(seq: Seq[Seq[Double]]) extends Sequence - final case class NestedInts(seq: Seq[Seq[Int]]) extends Sequence - final case class Strings(seq: Seq[String]) extends Sequence - final case class DateTimes(seq: Seq[LocalDateTime]) extends Sequence + final case class NestedInts(seq: Seq[Seq[Int]]) extends Sequence + final case class Strings(seq: Seq[String]) extends Sequence + final case class DateTimes(seq: Seq[LocalDateTime]) extends Sequence implicit def fromDoubleSeq(s: Seq[Double]): Sequence = Doubles(s) diff --git a/core/shared/src/main/scala/plotly/Trace.scala b/core/shared/src/main/scala/plotly/Trace.scala index 95c9139..f2823f6 100755 --- a/core/shared/src/main/scala/plotly/Trace.scala +++ b/core/shared/src/main/scala/plotly/Trace.scala @@ -2,7 +2,7 @@ package plotly import scala.language.implicitConversions -import java.lang.{ Boolean => JBoolean, Double => JDouble } +import java.lang.{Boolean => JBoolean, Double => JDouble} import dataclass._ import plotly.element._ @@ -10,29 +10,29 @@ import plotly.element._ sealed abstract class Trace extends Product with Serializable @data(optionSetters = true) class Scatter( - x: Option[Sequence] = None, - y: Option[Sequence] = None, - text: Option[OneOrSeq[String]] = None, - mode: Option[ScatterMode] = None, - marker: Option[Marker] = None, - line: Option[Line] = None, - textposition: Option[TextPosition] = None, - textfont: Option[TextFont] = None, - name: Option[String] = None, + x: Option[Sequence] = None, + y: Option[Sequence] = None, + text: Option[OneOrSeq[String]] = None, + mode: Option[ScatterMode] = None, + marker: Option[Marker] = None, + line: Option[Line] = None, + textposition: Option[TextPosition] = None, + textfont: Option[TextFont] = None, + name: Option[String] = None, connectgaps: Option[Boolean] = None, - xaxis: Option[AxisReference] = None, - yaxis: Option[AxisReference] = None, - fill: Option[Fill] = None, - error_x: Option[Error] = None, - error_y: Option[Error] = None, - showlegend: Option[Boolean] = None, - fillcolor: Option[OneOrSeq[Color]] = None, - hoverinfo: Option[HoverInfo] = None, - hoveron: Option[HoverOn] = None, - stackgroup: Option[String] = None, - groupnorm: Option[GroupNorm] = None, - @since("0.8.2") - hovertemplate: Option[OneOrSeq[String]] = None + xaxis: Option[AxisReference] = None, + yaxis: Option[AxisReference] = None, + fill: Option[Fill] = None, + error_x: Option[Error] = None, + error_y: Option[Error] = None, + showlegend: Option[Boolean] = None, + fillcolor: Option[OneOrSeq[Color]] = None, + hoverinfo: Option[HoverInfo] = None, + hoveron: Option[HoverOn] = None, + stackgroup: Option[String] = None, + groupnorm: Option[GroupNorm] = None, + @since("0.8.2") + hovertemplate: Option[OneOrSeq[String]] = None ) extends Trace object Scatter { @@ -44,32 +44,32 @@ object Scatter { @deprecated("Use Scatter() and chain-call .with* methods on it instead", "0.8.0") def apply( - 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 + 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 { case Some(y) => (Option(values), Some(y)) - case None => (None, Option(values)) + case None => (None, Option(values)) } Scatter( @@ -82,13 +82,13 @@ object Scatter { Option(textposition), Option(textfont), Option(name), - Option(connectgaps) .map(x => x: Boolean), + Option(connectgaps).map(x => x: Boolean), Option(xaxis), Option(yaxis), 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), @@ -99,21 +99,21 @@ object Scatter { } @data(optionSetters = true) class Box( - y: Option[Sequence] = None, - x: Option[Sequence] = None, - boxpoints: Option[BoxPoints] = None, - jitter: Option[Double] = None, - pointpos: Option[Double] = None, - name: Option[String] = None, - marker: Option[Marker] = None, + y: Option[Sequence] = None, + x: Option[Sequence] = None, + boxpoints: Option[BoxPoints] = None, + jitter: Option[Double] = None, + pointpos: Option[Double] = None, + name: Option[String] = None, + marker: Option[Marker] = None, orientation: Option[Orientation] = None, - whiskerwidth: Option[Double] = None, - boxmean: Option[BoxMean] = None, - fillcolor: Option[OneOrSeq[Color]] = None, - line: Option[Line] = None, - showlegend: Option[Boolean] = None, - @since("0.8.2") - hovertemplate: Option[OneOrSeq[String]] = None + whiskerwidth: Option[Double] = None, + boxmean: Option[BoxMean] = None, + fillcolor: Option[OneOrSeq[Color]] = None, + line: Option[Line] = None, + showlegend: Option[Boolean] = None, + @since("0.8.2") + hovertemplate: Option[OneOrSeq[String]] = None ) extends Trace object Box { @@ -125,99 +125,99 @@ object Box { @deprecated("Use Box() and chain-call .with* methods on it instead", "0.8.0") def apply( - y: Sequence = null, - x: Sequence = null, - boxpoints: BoxPoints = null, - jitter: JDouble = null, - pointpos: JDouble = null, - name: String = null, - marker: Marker = null, - orientation: Orientation = null, - whiskerwidth: JDouble = null, - boxmean: BoxMean = null, - fillcolor: OneOrSeq[Color] = null, - line: Line = null, - showlegend: JBoolean = null + y: Sequence = null, + x: Sequence = null, + boxpoints: BoxPoints = null, + jitter: JDouble = null, + pointpos: JDouble = null, + name: String = null, + marker: Marker = null, + orientation: Orientation = null, + whiskerwidth: JDouble = null, + boxmean: BoxMean = null, + fillcolor: OneOrSeq[Color] = null, + line: Line = null, + showlegend: JBoolean = null ): Box = Box( Option(y), Option(x), Option(boxpoints), - Option(jitter) .map(d => d: Double), - Option(pointpos) .map(d => d: Double), + Option(jitter).map(d => d: Double), + Option(pointpos).map(d => d: Double), Option(name), Option(marker), Option(orientation), - Option(whiskerwidth) .map(d => d: Double), + Option(whiskerwidth).map(d => d: Double), Option(boxmean), Option(fillcolor), Option(line), - Option(showlegend) .map(b => b: Boolean) + Option(showlegend).map(b => b: Boolean) ) } @data(optionSetters = true) class Image( - z: Seq[Seq[Seq[Double]]], - x0: Option[Element] = None, - y0: Option[Element] = None, - name: Option[String] = None, - text: Option[Seq[String]] = None, - opacity: Option[Double] = None, - ids: Option[Seq[String]] = None, - dx: Option[Double] = None, - dy: Option[Double] = None, - source: Option[String] = None, - hoverinfo: Option[HoverInfo] = None, - hovertemplate: Option[Seq[String]] = None, - meta: Option[String] = None, - customdata: Option[Seq[String]] = None, - xaxis: Option[AxisReference] = None, - yaxis: Option[AxisReference] = None, - colormodel: Option[ColorModel] = None, - zmax: Option[Seq[Double]] = None, - zmin: Option[Seq[Double]] = None, - hoverlabel: Option[HoverLabel] = None + z: Seq[Seq[Seq[Double]]], + x0: Option[Element] = None, + y0: Option[Element] = None, + name: Option[String] = None, + text: Option[Seq[String]] = None, + opacity: Option[Double] = None, + ids: Option[Seq[String]] = None, + dx: Option[Double] = None, + dy: Option[Double] = None, + source: Option[String] = None, + hoverinfo: Option[HoverInfo] = None, + hovertemplate: Option[Seq[String]] = None, + meta: Option[String] = None, + customdata: Option[Seq[String]] = None, + xaxis: Option[AxisReference] = None, + yaxis: Option[AxisReference] = None, + colormodel: Option[ColorModel] = None, + zmax: Option[Seq[Double]] = None, + zmin: Option[Seq[Double]] = None, + hoverlabel: Option[HoverLabel] = None ) extends Trace @data(optionSetters = true) class Bar( - x: Sequence, - y: Sequence, - @since - name: Option[String] = None, - text: Option[Seq[String]] = None, - marker: Option[Marker] = None, + x: Sequence, + y: Sequence, + @since + name: Option[String] = None, + text: Option[Seq[String]] = None, + marker: Option[Marker] = None, orientation: Option[Orientation] = None, - xaxis: Option[AxisReference] = None, - yaxis: Option[AxisReference] = None, - error_y: Option[Error] = None, - showlegend: Option[Boolean] = None, - hoverinfo: Option[HoverInfo] = None, - textposition: Option[BarTextPosition] = None, - opacity: Option[Double] = None, - width: Option[OneOrSeq[Double]] = None, - base: Option[OneOrSeq[Double]] = None, - @since("0.8.2") - hovertemplate: Option[OneOrSeq[String]] = None + xaxis: Option[AxisReference] = None, + yaxis: Option[AxisReference] = None, + error_y: Option[Error] = None, + showlegend: Option[Boolean] = None, + hoverinfo: Option[HoverInfo] = None, + textposition: Option[BarTextPosition] = None, + opacity: Option[Double] = None, + width: Option[OneOrSeq[Double]] = None, + base: Option[OneOrSeq[Double]] = None, + @since("0.8.2") + hovertemplate: Option[OneOrSeq[String]] = None ) extends Trace object Bar { @deprecated("Use Bar() and chain-call .with* methods on it instead", "0.8.0") 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, - hoverinfo: HoverInfo = null, - textposition: BarTextPosition = null, - opacity: JDouble = null, - width: OneOrSeq[Double] = null, - base: OneOrSeq[Double] = 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, @@ -229,29 +229,29 @@ 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(opacity).map(d => d: Double), Option(width), Option(base) ) } @data(optionSetters = true) class Histogram( - x: Option[Sequence] = None, - y: Option[Sequence] = None, - opacity: Option[Double] = None, - name: Option[String] = None, - autobinx: Option[Boolean] = None, - marker: Option[Marker] = None, - xbins: Option[Bins] = None, - histnorm: Option[HistNorm] = None, - showlegend: Option[Boolean] = None, - cumulative: Option[Cumulative] = None, - histfunc: Option[HistFunc] = None, - @since("0.8.2") - hovertemplate: Option[OneOrSeq[String]] = None + x: Option[Sequence] = None, + y: Option[Sequence] = None, + opacity: Option[Double] = None, + name: Option[String] = None, + autobinx: Option[Boolean] = None, + marker: Option[Marker] = None, + xbins: Option[Bins] = None, + histnorm: Option[HistNorm] = None, + showlegend: Option[Boolean] = None, + cumulative: Option[Cumulative] = None, + histfunc: Option[HistFunc] = None, + @since("0.8.2") + hovertemplate: Option[OneOrSeq[String]] = None ) extends Trace object Histogram { @@ -263,71 +263,71 @@ object Histogram { @deprecated("Use Histogram() and chain-call .with* methods on it instead", "0.8.0") 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, - cumulative: Cumulative = null, - histfunc: HistFunc = 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), Option(y), - Option(opacity) .map(d => d: Double), + Option(opacity).map(d => d: Double), Option(name), - Option(autobinx) .map(b => b: Boolean), + Option(autobinx).map(b => b: Boolean), Option(marker), Option(xbins), Option(histnorm), - Option(showlegend) .map(b => b: Boolean), + Option(showlegend).map(b => b: Boolean), Option(cumulative), Option(histfunc) ) } @data(optionSetters = true) class Surface( - x: Option[Sequence] = None, - y: Option[Sequence] = None, - z: Option[Sequence] = None, - showscale: Option[Boolean] = None, - opacity: Option[Double] = None, - @since("0.8.2") - hovertemplate: Option[OneOrSeq[String]] = None + x: Option[Sequence] = None, + y: Option[Sequence] = None, + z: Option[Sequence] = None, + showscale: Option[Boolean] = None, + opacity: Option[Double] = None, + @since("0.8.2") + hovertemplate: Option[OneOrSeq[String]] = None ) extends Trace object Surface { @deprecated("Use Surface() and chain-call .with* methods on it instead", "0.8.0") def apply( - x: Sequence = null, - y: Sequence = null, - z: Sequence = null, - showscale: JBoolean = null, - opacity: JDouble = null + 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) + Option(showscale).map(b => b: Boolean), + Option(opacity).map(d => d: Double) ) } @data(optionSetters = true) class Heatmap( - y: Option[Sequence] = None, - x: Option[Sequence] = None, - z: Option[Sequence] = None, - autocolorscale: Option[Boolean] = None, - colorscale: Option[ColorScale] = None, - showscale: Option[Boolean] = None, - name: Option[String] = None, - @since("0.8.2") - hovertemplate: Option[OneOrSeq[String]] = None, + y: Option[Sequence] = None, + x: Option[Sequence] = None, + z: Option[Sequence] = None, + autocolorscale: Option[Boolean] = None, + colorscale: Option[ColorScale] = None, + showscale: Option[Boolean] = None, + name: Option[String] = None, + @since("0.8.2") + hovertemplate: Option[OneOrSeq[String]] = None, hoverongaps: Option[Boolean] = None ) extends Trace @@ -340,51 +340,51 @@ object Heatmap { @deprecated("Use Heatmap() and chain-call .with* methods on it instead", "0.8.0") def apply( - y: Sequence = null, - x: Sequence = null, - z: Sequence = null, - autocolorscale: JBoolean = null, - colorscale: ColorScale = null, - showscale: JBoolean = null, - name: String = null + y: Sequence = null, + x: Sequence = null, + z: Sequence = null, + autocolorscale: JBoolean = null, + colorscale: ColorScale = null, + showscale: JBoolean = null, + name: String = null ): Heatmap = Heatmap( Option(y), Option(x), Option(z), - Option(autocolorscale) .map(b => b: Boolean), + Option(autocolorscale).map(b => b: Boolean), Option(colorscale), - Option(showscale) .map(b => b: Boolean), + Option(showscale).map(b => b: Boolean), Option(name) ) } @data(optionSetters = true) class Candlestick( - x: Option[Sequence] = None, - close: Option[Sequence] = None, - high: Option[Sequence] = None, - low: Option[Sequence] = None, - open: Option[Sequence] = None, - decreasing: Option[Marker] = None, - increasing: Option[Marker] = None, - line: Option[Marker] = None, - xaxis: Option[AxisReference] = None, - yaxis: Option[AxisReference] = None + x: Option[Sequence] = None, + close: Option[Sequence] = None, + high: Option[Sequence] = None, + low: Option[Sequence] = None, + open: Option[Sequence] = None, + decreasing: Option[Marker] = None, + increasing: Option[Marker] = None, + line: Option[Marker] = None, + xaxis: Option[AxisReference] = None, + yaxis: Option[AxisReference] = None ) extends Trace object Candlestick { @deprecated("Use Candlestick() and chain-call .with* methods on it instead", "0.8.0") def apply( - x: Sequence = null, - close: Sequence = null, - high: Sequence = null, - low: Sequence = null, - open: Sequence = null, - decreasing: Marker = null, - increasing: Marker = null, - line: Marker = null, - xaxis: AxisReference = null, - yaxis: AxisReference = null + x: Sequence = null, + close: Sequence = null, + high: Sequence = null, + low: Sequence = null, + open: Sequence = null, + decreasing: Marker = null, + increasing: Marker = null, + line: Marker = null, + xaxis: AxisReference = null, + yaxis: AxisReference = null ): Candlestick = Candlestick( Option(x), diff --git a/core/shared/src/main/scala/plotly/element/Alignment.scala b/core/shared/src/main/scala/plotly/element/Alignment.scala index b09395a..c504391 100644 --- a/core/shared/src/main/scala/plotly/element/Alignment.scala +++ b/core/shared/src/main/scala/plotly/element/Alignment.scala @@ -3,7 +3,7 @@ package plotly.element sealed abstract class Alignment(val label: String) extends Product with Serializable object Alignment { - case object Left extends Alignment("left") + case object Left extends Alignment("left") case object Right extends Alignment("right") - case object Auto extends Alignment("auto") + case object Auto extends Alignment("auto") } diff --git a/core/shared/src/main/scala/plotly/element/Anchor.scala b/core/shared/src/main/scala/plotly/element/Anchor.scala index a3ed33f..c1204e0 100644 --- a/core/shared/src/main/scala/plotly/element/Anchor.scala +++ b/core/shared/src/main/scala/plotly/element/Anchor.scala @@ -4,10 +4,10 @@ package element sealed abstract class Anchor(val label: String) extends Product with Serializable object Anchor { - case object Left extends Anchor("left") + case object Left extends Anchor("left") case object Center extends Anchor("center") - case object Right extends Anchor("right") - case object Top extends Anchor("top") + case object Right extends Anchor("right") + case object Top extends Anchor("top") case object Middle extends Anchor("middle") case object Bottom extends Anchor("bottom") } diff --git a/core/shared/src/main/scala/plotly/element/AxisAnchor.scala b/core/shared/src/main/scala/plotly/element/AxisAnchor.scala index 7ba251a..0ba8315 100644 --- a/core/shared/src/main/scala/plotly/element/AxisAnchor.scala +++ b/core/shared/src/main/scala/plotly/element/AxisAnchor.scala @@ -7,6 +7,6 @@ sealed abstract class AxisAnchor(val label: String) extends Product with Seriali object AxisAnchor { @data class Reference(axisReference: AxisReference) extends AxisAnchor(axisReference.label) - case object Free extends AxisAnchor("free") - case object Y extends AxisAnchor("y") + case object Free extends AxisAnchor("free") + case object Y extends AxisAnchor("y") } diff --git a/core/shared/src/main/scala/plotly/element/AxisReference.scala b/core/shared/src/main/scala/plotly/element/AxisReference.scala index fd07a01..8a326d7 100644 --- a/core/shared/src/main/scala/plotly/element/AxisReference.scala +++ b/core/shared/src/main/scala/plotly/element/AxisReference.scala @@ -4,12 +4,12 @@ package element sealed abstract class AxisReference(val label: String) extends Product with Serializable object AxisReference { - case object X extends AxisReference("x") + case object X extends AxisReference("x") case object X1 extends AxisReference("x1") case object X2 extends AxisReference("x2") case object X3 extends AxisReference("x3") case object X4 extends AxisReference("x4") - case object Y extends AxisReference("y") + case object Y extends AxisReference("y") case object Y1 extends AxisReference("y1") case object Y2 extends AxisReference("y2") case object Y3 extends AxisReference("y3") diff --git a/core/shared/src/main/scala/plotly/element/AxisType.scala b/core/shared/src/main/scala/plotly/element/AxisType.scala index 417c560..5c7325f 100644 --- a/core/shared/src/main/scala/plotly/element/AxisType.scala +++ b/core/shared/src/main/scala/plotly/element/AxisType.scala @@ -4,10 +4,11 @@ package element sealed abstract class AxisType(val label: String) extends Product with Serializable object AxisType { + /** Lets plotly guess from data */ - case object Default extends AxisType("-") - case object Linear extends AxisType("linear") - case object Log extends AxisType("log") - case object Date extends AxisType("date") + case object Default extends AxisType("-") + case object Linear extends AxisType("linear") + case object Log extends AxisType("log") + case object Date extends AxisType("date") case object Category extends AxisType("category") } diff --git a/core/shared/src/main/scala/plotly/element/Bins.scala b/core/shared/src/main/scala/plotly/element/Bins.scala index f8e091c..1a2b038 100644 --- a/core/shared/src/main/scala/plotly/element/Bins.scala +++ b/core/shared/src/main/scala/plotly/element/Bins.scala @@ -3,7 +3,7 @@ package plotly.element import dataclass.data @data class Bins( - start: Double, - end: Double, - size: Double + start: Double, + end: Double, + size: Double ) diff --git a/core/shared/src/main/scala/plotly/element/BoxMean.scala b/core/shared/src/main/scala/plotly/element/BoxMean.scala index 9a0d67f..f1e9a70 100644 --- a/core/shared/src/main/scala/plotly/element/BoxMean.scala +++ b/core/shared/src/main/scala/plotly/element/BoxMean.scala @@ -6,10 +6,10 @@ import dataclass.data sealed abstract class BoxMean extends Product with Serializable object BoxMean { - @data class Bool(value: Boolean) extends BoxMean + @data class Bool(value: Boolean) extends BoxMean sealed abstract class Labeled(val label: String) extends BoxMean - val True = Bool(true) + val True = Bool(true) val False = Bool(false) case object SD extends Labeled("sd") diff --git a/core/shared/src/main/scala/plotly/element/BoxPoints.scala b/core/shared/src/main/scala/plotly/element/BoxPoints.scala index 6fd5398..09d8232 100644 --- a/core/shared/src/main/scala/plotly/element/BoxPoints.scala +++ b/core/shared/src/main/scala/plotly/element/BoxPoints.scala @@ -6,13 +6,13 @@ import dataclass.data sealed abstract class BoxPoints extends Product with Serializable object BoxPoints { - @data class Bool(value: Boolean) extends BoxPoints + @data class Bool(value: Boolean) extends BoxPoints sealed abstract class Labeled(val label: String) extends BoxPoints val False = Bool(false) - val True = Bool(true) + val True = Bool(true) - case object All extends Labeled("all") + case object All extends Labeled("all") case object SuspectedOutliers extends Labeled("suspectedoutliers") - case object Outliers extends Labeled("Outliers") // FIXME case? + case object Outliers extends Labeled("Outliers") // FIXME case? } diff --git a/core/shared/src/main/scala/plotly/element/ColorModel.scala b/core/shared/src/main/scala/plotly/element/ColorModel.scala index de972dc..cec1d9a 100644 --- a/core/shared/src/main/scala/plotly/element/ColorModel.scala +++ b/core/shared/src/main/scala/plotly/element/ColorModel.scala @@ -3,9 +3,9 @@ package plotly.element sealed abstract class ColorModel(val label: String) extends Product with Serializable object ColorModel { - case object RGB extends ColorModel("rgb") - case object RGBA extends ColorModel("rgba") + case object RGB extends ColorModel("rgb") + case object RGBA extends ColorModel("rgba") case object RGBA256 extends ColorModel("rgba256") - case object HSL extends ColorModel("hsl") - case object HSLA extends ColorModel("hsla") + case object HSL extends ColorModel("hsl") + case object HSLA extends ColorModel("hsla") } diff --git a/core/shared/src/main/scala/plotly/element/ColorScale.scala b/core/shared/src/main/scala/plotly/element/ColorScale.scala index cefb566..c99d947 100755 --- a/core/shared/src/main/scala/plotly/element/ColorScale.scala +++ b/core/shared/src/main/scala/plotly/element/ColorScale.scala @@ -5,5 +5,5 @@ sealed abstract class ColorScale extends Product with Serializable object ColorScale { @data class CustomScale(values: Seq[(Double, Color)]) extends ColorScale - @data class NamedScale(name: String) extends ColorScale -} \ No newline at end of file + @data class NamedScale(name: String) extends ColorScale +} diff --git a/core/shared/src/main/scala/plotly/element/Error.scala b/core/shared/src/main/scala/plotly/element/Error.scala index 0557211..4f0ae7a 100644 --- a/core/shared/src/main/scala/plotly/element/Error.scala +++ b/core/shared/src/main/scala/plotly/element/Error.scala @@ -1,7 +1,7 @@ package plotly package element -import java.lang.{ Boolean => JBoolean, Double => JDouble } +import java.lang.{Boolean => JBoolean, Double => JDouble} import dataclass._ @@ -9,20 +9,20 @@ sealed abstract class Error(val `type`: String) extends Product with Serializabl object Error { @data(optionSetters = true) class Data( - array: Seq[Double], - @since - visible: Option[Boolean] = None, - symmetric: Option[Boolean] = None, - arrayminus: Option[Seq[Double]] = None + array: Seq[Double], + @since + visible: Option[Boolean] = None, + symmetric: Option[Boolean] = None, + arrayminus: Option[Seq[Double]] = None ) extends Error("data") object Data { @deprecated("Use Data(array) and chain-call .with* methods on it instead", "0.8.0") def apply( - array: Seq[Double], - visible: JBoolean = null, - symmetric: JBoolean = null, - arrayminus: Seq[Double] = null + array: Seq[Double], + visible: JBoolean = null, + symmetric: JBoolean = null, + arrayminus: Seq[Double] = null ): Data = Data( array, @@ -33,20 +33,20 @@ object Error { } @data(optionSetters = true) class Percent( - value: Double, - @since - visible: Option[Boolean] = None, - symmetric: Option[Boolean] = None, - valueminus: Option[Double] = None + value: Double, + @since + visible: Option[Boolean] = None, + symmetric: Option[Boolean] = None, + valueminus: Option[Double] = None ) extends Error("percent") object Percent { @deprecated("Use Percent(value) and chain-call .with* methods on it instead", "0.8.0") def apply( - value: Double, - visible: JBoolean = null, - symmetric: JBoolean = null, - valueminus: JDouble = null + value: Double, + visible: JBoolean = null, + symmetric: JBoolean = null, + valueminus: JDouble = null ): Percent = Percent( value, @@ -57,21 +57,21 @@ object Error { } @data(optionSetters = true) class Constant( - value: Double, - color: Option[String] = None, - thickness: Option[Double] = None, + value: Double, + color: Option[String] = None, + thickness: Option[Double] = None, opacity: Option[Double] = None, - width: Option[Double] = None + width: Option[Double] = None ) extends Error("constant") object Constant { @deprecated("Use Constant(value) and chain-call .with* methods on it instead", "0.8.0") def apply( - value: Double, - color: String = null, - thickness: JDouble = null, + value: Double, + color: String = null, + thickness: JDouble = null, opacity: JDouble = null, - width: JDouble = null + width: JDouble = null ): Constant = Constant( value, diff --git a/core/shared/src/main/scala/plotly/element/GroupNorm.scala b/core/shared/src/main/scala/plotly/element/GroupNorm.scala index 10246d7..03deecb 100644 --- a/core/shared/src/main/scala/plotly/element/GroupNorm.scala +++ b/core/shared/src/main/scala/plotly/element/GroupNorm.scala @@ -4,5 +4,5 @@ sealed abstract class GroupNorm(val label: String) extends Product with Serializ object GroupNorm { case object Fraction extends GroupNorm("fraction") - case object Percent extends GroupNorm("percent") + case object Percent extends GroupNorm("percent") } diff --git a/core/shared/src/main/scala/plotly/element/HistFunc.scala b/core/shared/src/main/scala/plotly/element/HistFunc.scala index 2d37a7d..4aabca5 100644 --- a/core/shared/src/main/scala/plotly/element/HistFunc.scala +++ b/core/shared/src/main/scala/plotly/element/HistFunc.scala @@ -4,10 +4,10 @@ sealed abstract class HistFunc(val label: String) extends Product with Serializa object HistFunc { - case object Count extends HistFunc("count") - case object Sum extends HistFunc("sum") + 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") + case object Min extends HistFunc("min") + case object Max extends HistFunc("max") } diff --git a/core/shared/src/main/scala/plotly/element/HistNorm.scala b/core/shared/src/main/scala/plotly/element/HistNorm.scala index 694062f..fa619ce 100644 --- a/core/shared/src/main/scala/plotly/element/HistNorm.scala +++ b/core/shared/src/main/scala/plotly/element/HistNorm.scala @@ -3,9 +3,9 @@ package plotly.element sealed abstract class HistNorm(val label: String) extends Product with Serializable object HistNorm { - case object Count extends HistNorm("count") - case object Percent extends HistNorm("percent") - case object Probability extends HistNorm("probability") - case object Density extends HistNorm("density") + case object Count extends HistNorm("count") + case object Percent extends HistNorm("percent") + case object Probability extends HistNorm("probability") + case object Density extends HistNorm("density") case object ProbabilityDensity extends HistNorm("probability density") } diff --git a/core/shared/src/main/scala/plotly/element/HoverInfo.scala b/core/shared/src/main/scala/plotly/element/HoverInfo.scala index 02fe23c..de8d8b2 100644 --- a/core/shared/src/main/scala/plotly/element/HoverInfo.scala +++ b/core/shared/src/main/scala/plotly/element/HoverInfo.scala @@ -6,23 +6,21 @@ sealed abstract class HoverInfo extends Product with Serializable { object HoverInfo { - def all: HoverInfo = All + 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 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 Color extends Element("color") - case object All extends HoverInfo { def label = "all" } diff --git a/core/shared/src/main/scala/plotly/element/HoverLabel.scala b/core/shared/src/main/scala/plotly/element/HoverLabel.scala index 3938063..1534216 100644 --- a/core/shared/src/main/scala/plotly/element/HoverLabel.scala +++ b/core/shared/src/main/scala/plotly/element/HoverLabel.scala @@ -3,10 +3,10 @@ package plotly.element import dataclass.data @data(optionSetters = true) class HoverLabel( - bgcolor: Option[OneOrSeq[Color]] = None, - bordercolor: Option[OneOrSeq[Color]] = None, - font: Option[HoverLabelFont] = None, - align: Option[OneOrSeq[Alignment]] = None, - namelength: Option[OneOrSeq[Int]] = None, - uirevision: Option[Element] = None + bgcolor: Option[OneOrSeq[Color]] = None, + bordercolor: Option[OneOrSeq[Color]] = None, + font: Option[HoverLabelFont] = None, + align: Option[OneOrSeq[Alignment]] = None, + namelength: Option[OneOrSeq[Int]] = None, + uirevision: Option[Element] = None ) diff --git a/core/shared/src/main/scala/plotly/element/HoverLabelFont.scala b/core/shared/src/main/scala/plotly/element/HoverLabelFont.scala index f6384c1..7b83953 100644 --- a/core/shared/src/main/scala/plotly/element/HoverLabelFont.scala +++ b/core/shared/src/main/scala/plotly/element/HoverLabelFont.scala @@ -3,7 +3,7 @@ package plotly.element import dataclass.data @data(optionSetters = true) class HoverLabelFont( - family: Option[OneOrSeq[String]] = None, - size: Option[OneOrSeq[Double]] = None, - color: Option[OneOrSeq[Color]] = None + family: Option[OneOrSeq[String]] = None, + size: Option[OneOrSeq[Double]] = None, + color: Option[OneOrSeq[Color]] = None ) diff --git a/core/shared/src/main/scala/plotly/element/HoverOn.scala b/core/shared/src/main/scala/plotly/element/HoverOn.scala index 2eeec68..6cbc68f 100644 --- a/core/shared/src/main/scala/plotly/element/HoverOn.scala +++ b/core/shared/src/main/scala/plotly/element/HoverOn.scala @@ -3,7 +3,7 @@ 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 Points extends HoverOn("points") + case object Fills extends HoverOn("fills") case object PointsFill extends HoverOn("points+fills") } diff --git a/core/shared/src/main/scala/plotly/element/Line.scala b/core/shared/src/main/scala/plotly/element/Line.scala index 4702737..05168d4 100644 --- a/core/shared/src/main/scala/plotly/element/Line.scala +++ b/core/shared/src/main/scala/plotly/element/Line.scala @@ -3,26 +3,26 @@ package element import dataclass.data -import java.lang.{ Double => JDouble } +import java.lang.{Double => JDouble} @data(optionSetters = true) class Line( - shape: Option[LineShape] = None, - color: Option[OneOrSeq[Color]] = None, - width: Option[OneOrSeq[Double]] = None, - dash: Option[Dash] = None, - outliercolor: Option[Color] = None, - outlierwidth: Option[Double] = None + shape: Option[LineShape] = None, + color: Option[OneOrSeq[Color]] = None, + width: Option[OneOrSeq[Double]] = None, + dash: Option[Dash] = None, + outliercolor: Option[Color] = None, + outlierwidth: Option[Double] = None ) object Line { @deprecated("Use Line() and chain-call .with* methods on it instead", "0.8.0") def apply( - shape: LineShape = null, - color: OneOrSeq[Color] = null, - width: OneOrSeq[Double] = null, - dash: Dash = null, - outliercolor: Color = null, - outlierwidth: JDouble = null + shape: LineShape = null, + color: OneOrSeq[Color] = null, + width: OneOrSeq[Double] = null, + dash: Dash = null, + outliercolor: Color = null, + outlierwidth: JDouble = null ): Line = Line( Option(shape), @@ -30,6 +30,6 @@ object Line { Option(width), Option(dash), Option(outliercolor), - Option(outlierwidth) .map(x => x: Double) + Option(outlierwidth).map(x => x: Double) ) } diff --git a/core/shared/src/main/scala/plotly/element/LineShape.scala b/core/shared/src/main/scala/plotly/element/LineShape.scala index 70637e5..d9a9861 100644 --- a/core/shared/src/main/scala/plotly/element/LineShape.scala +++ b/core/shared/src/main/scala/plotly/element/LineShape.scala @@ -6,8 +6,8 @@ sealed abstract class LineShape(val label: String) extends Product with Serializ object LineShape { case object Linear extends LineShape("linear") case object Spline extends LineShape("spline") - case object VHV extends LineShape("vhv") - case object HVH extends LineShape("hvh") - case object VH extends LineShape("vh") - case object HV extends LineShape("hv") + case object VHV extends LineShape("vhv") + case object HVH extends LineShape("hvh") + case object VH extends LineShape("vh") + case object HV extends LineShape("hv") } diff --git a/core/shared/src/main/scala/plotly/element/LocalDateTime.scala b/core/shared/src/main/scala/plotly/element/LocalDateTime.scala index 271177d..e140fa5 100644 --- a/core/shared/src/main/scala/plotly/element/LocalDateTime.scala +++ b/core/shared/src/main/scala/plotly/element/LocalDateTime.scala @@ -5,12 +5,12 @@ import dataclass.data import scala.util.Try @data class LocalDateTime( - year: Int, - month: Int, - dayOfMonth: Int, - hour: Int, - minute: Int, - second: Int + year: Int, + month: Int, + dayOfMonth: Int, + hour: Int, + minute: Int, + second: Int ) { override def toString: String = f"$year-$month%02d-$dayOfMonth%02d $hour%02d:$minute%02d:$second%02d" @@ -20,8 +20,7 @@ object LocalDateTime extends PlotlyJavaTimeConversions { private object IntStr { def unapply(s: String): Option[Int] = - Try(s.toInt) - .toOption + Try(s.toInt).toOption } def parse(s: String): Option[LocalDateTime] = diff --git a/core/shared/src/main/scala/plotly/element/Marker.scala b/core/shared/src/main/scala/plotly/element/Marker.scala index 50b4074..5efb90b 100644 --- a/core/shared/src/main/scala/plotly/element/Marker.scala +++ b/core/shared/src/main/scala/plotly/element/Marker.scala @@ -1,34 +1,34 @@ package plotly package element -import java.lang.{ Double => JDouble } +import java.lang.{Double => JDouble} import dataclass.data @data(optionSetters = true) class Marker( - size: Option[OneOrSeq[Int]] = None, - color: Option[OneOrSeq[Color]] = None, - opacity: Option[OneOrSeq[Double]] = None, - line: Option[Line] = None, - symbol: Option[OneOrSeq[Symbol]] = None, - outliercolor: Option[Color] = None, - sizeref: Option[Double] = None, - sizemode: Option[SizeMode] = None, - width: Option[OneOrSeq[Int]] = None + size: Option[OneOrSeq[Int]] = None, + color: Option[OneOrSeq[Color]] = None, + opacity: Option[OneOrSeq[Double]] = None, + line: Option[Line] = None, + symbol: Option[OneOrSeq[Symbol]] = None, + outliercolor: Option[Color] = None, + sizeref: Option[Double] = None, + sizemode: Option[SizeMode] = None, + width: Option[OneOrSeq[Int]] = None ) object Marker { @deprecated("Use Marker() and chain-call .with* methods on it instead", "0.8.0") def apply( - size: OneOrSeq[Int] = null, - color: OneOrSeq[Color] = null, - opacity: OneOrSeq[Double] = null, - line: Line = null, - symbol: OneOrSeq[Symbol] = null, - outliercolor: Color = null, - sizeref: JDouble = null, - sizemode: SizeMode = null, - width: OneOrSeq[Int] = null + size: OneOrSeq[Int] = null, + color: OneOrSeq[Color] = null, + opacity: OneOrSeq[Double] = null, + line: Line = null, + symbol: OneOrSeq[Symbol] = null, + outliercolor: Color = null, + sizeref: JDouble = null, + sizemode: SizeMode = null, + width: OneOrSeq[Int] = null ): Marker = Marker( Option(size), diff --git a/core/shared/src/main/scala/plotly/element/OneOrSeq.scala b/core/shared/src/main/scala/plotly/element/OneOrSeq.scala index 3372b7f..c4c32a0 100644 --- a/core/shared/src/main/scala/plotly/element/OneOrSeq.scala +++ b/core/shared/src/main/scala/plotly/element/OneOrSeq.scala @@ -5,7 +5,7 @@ import scala.language.implicitConversions sealed abstract class OneOrSeq[T] extends Product with Serializable object OneOrSeq { - case class One[T](value: T) extends OneOrSeq[T] + case class One[T](value: T) extends OneOrSeq[T] case class Sequence[T](seq: Seq[T]) extends OneOrSeq[T] implicit def fromOne[T](value: T): OneOrSeq[T] = diff --git a/core/shared/src/main/scala/plotly/element/ScatterMode.scala b/core/shared/src/main/scala/plotly/element/ScatterMode.scala index b66dd25..0747e80 100644 --- a/core/shared/src/main/scala/plotly/element/ScatterMode.scala +++ b/core/shared/src/main/scala/plotly/element/ScatterMode.scala @@ -12,9 +12,9 @@ object ScatterMode { sealed abstract class Flag(val label: String) extends Product with Serializable case object Markers extends Flag("markers") - case object Text extends Flag("text") - case object Lines extends Flag("lines") + case object Text extends Flag("text") + case object Lines extends Flag("lines") - val flags = Seq(Markers, Text, Lines) + val flags = Seq(Markers, Text, Lines) val flagMap = flags.map(m => m.label -> m).toMap } diff --git a/core/shared/src/main/scala/plotly/element/Side.scala b/core/shared/src/main/scala/plotly/element/Side.scala index cd37d3b..0e0137a 100644 --- a/core/shared/src/main/scala/plotly/element/Side.scala +++ b/core/shared/src/main/scala/plotly/element/Side.scala @@ -4,8 +4,8 @@ package element sealed abstract class Side(val label: String) extends Product with Serializable object Side { - case object Left extends Side("left") - case object Right extends Side("right") - case object Top extends Side("top") + case object Left extends Side("left") + case object Right extends Side("right") + case object Top extends Side("top") case object Bottom extends Side("bottom") } diff --git a/core/shared/src/main/scala/plotly/element/SizeMode.scala b/core/shared/src/main/scala/plotly/element/SizeMode.scala index 578e597..7a453ff 100644 --- a/core/shared/src/main/scala/plotly/element/SizeMode.scala +++ b/core/shared/src/main/scala/plotly/element/SizeMode.scala @@ -4,5 +4,5 @@ sealed abstract class SizeMode(val label: String) extends Product with Serializa object SizeMode { case object Diameter extends SizeMode("diameter") - case object Area extends SizeMode("area") + case object Area extends SizeMode("area") } diff --git a/core/shared/src/main/scala/plotly/element/Symbol.scala b/core/shared/src/main/scala/plotly/element/Symbol.scala index 1817a31..ede2a32 100644 --- a/core/shared/src/main/scala/plotly/element/Symbol.scala +++ b/core/shared/src/main/scala/plotly/element/Symbol.scala @@ -3,22 +3,22 @@ package element import dataclass.data sealed abstract class Symbol(label0: String, idx0: Int) extends Product with Serializable { - def idx: Int = idx0 + (if (open) 100 else 0) - def label: String = label0 + (if (open) "-open" else "") + def idx: Int = idx0 + (if (open) 100 else 0) + def label: String = label0 + (if (open) "-open" else "") def open: Boolean } object Symbol { sealed abstract class DotSymbol(label0: String, idx0: Int) extends Symbol(label0, idx0) { - override def idx: Int = super.idx + (if (dot) 200 else 0) + override def idx: Int = super.idx + (if (dot) 200 else 0) override def label: String = super.label + (if (dot) "-dot" else "") def dot: Boolean } - @data class Circle(open: Boolean = false, dot: Boolean = false) extends DotSymbol("circle", 0) - @data class Square(open: Boolean = false, dot: Boolean = false) extends DotSymbol("square", 1) + @data class Circle(open: Boolean = false, dot: Boolean = false) extends DotSymbol("circle", 0) + @data class Square(open: Boolean = false, dot: Boolean = false) extends DotSymbol("square", 1) @data class Diamond(open: Boolean = false, dot: Boolean = false) extends DotSymbol("diamond", 2) - @data class Cross(open: Boolean = false, dot: Boolean = false) extends DotSymbol("cross", 3) + @data class Cross(open: Boolean = false, dot: Boolean = false) extends DotSymbol("cross", 3) /* "4" | "x" | "104" | "x-open" | "204" | "x-dot" | "304" | "x-open-dot" @@ -62,5 +62,5 @@ object Symbol { "42" | "line-ns" | "142" | "line-ns-open" "43" | "line-ne" | "143" | "line-ne-open" "44" | "line-nw" | "144" | "line-nw-open - */ + */ } diff --git a/core/shared/src/main/scala/plotly/element/TickMode.scala b/core/shared/src/main/scala/plotly/element/TickMode.scala index 9c5bd9c..2cfb97d 100644 --- a/core/shared/src/main/scala/plotly/element/TickMode.scala +++ b/core/shared/src/main/scala/plotly/element/TickMode.scala @@ -3,9 +3,7 @@ package plotly.element sealed abstract class TickMode(val mode: String) extends Product with Serializable object TickMode { - case object Auto extends TickMode("auto") + case object Auto extends TickMode("auto") case object Linear extends TickMode("linear") - case object Array extends TickMode("array") + case object Array extends TickMode("array") } - - diff --git a/core/shared/src/main/scala/plotly/element/Ticks.scala b/core/shared/src/main/scala/plotly/element/Ticks.scala index 90dc43d..bd2256a 100755 --- a/core/shared/src/main/scala/plotly/element/Ticks.scala +++ b/core/shared/src/main/scala/plotly/element/Ticks.scala @@ -5,6 +5,6 @@ sealed abstract class Ticks(val label: String) extends Product with Serializable object Ticks { case object Outside extends Ticks("outside") - case object Inside extends Ticks("inside") - case object Empty extends Ticks("") + case object Inside extends Ticks("inside") + case object Empty extends Ticks("") } diff --git a/core/shared/src/main/scala/plotly/layout/Annotation.scala b/core/shared/src/main/scala/plotly/layout/Annotation.scala index 9e1a047..a12d873 100644 --- a/core/shared/src/main/scala/plotly/layout/Annotation.scala +++ b/core/shared/src/main/scala/plotly/layout/Annotation.scala @@ -1,38 +1,38 @@ package plotly package layout -import java.lang.{ Boolean => JBoolean, Double => JDouble } +import java.lang.{Boolean => JBoolean, Double => JDouble} import dataclass.data import plotly.element._ @data(optionSetters = true) class Annotation( - xref: Option[Ref] = None, - yref: Option[Ref] = None, - x: Option[Element] = None, - y: Option[Element] = None, + xref: Option[Ref] = None, + yref: Option[Ref] = None, + x: Option[Element] = None, + y: Option[Element] = None, xanchor: Option[Anchor] = None, yanchor: Option[Anchor] = None, - text: Option[Element] = None, - font: Option[Font] = None, - showarrow: Option[Boolean] = None, - @since("0.8.0") - ax: Option[Double] = None, - ay: Option[Double] = None + text: Option[Element] = None, + font: Option[Font] = None, + showarrow: Option[Boolean] = None, + @since("0.8.0") + ax: Option[Double] = None, + ay: Option[Double] = None ) object Annotation { @deprecated("Use Annotation() and chain-call .with* methods on it instead", "0.8.0") def apply( - xref: Ref = null, - yref: Ref = null, - x: Element = null, - y: Element = null, - xanchor: Anchor = null, - yanchor: Anchor = null, - text: Element = null, - font: Font = null, - showarrow: JBoolean = null + xref: Ref = null, + yref: Ref = null, + x: Element = null, + y: Element = null, + xanchor: Anchor = null, + yanchor: Anchor = null, + text: Element = null, + font: Font = null, + showarrow: JBoolean = null ): Annotation = Annotation( Option(xref), diff --git a/core/shared/src/main/scala/plotly/layout/Axis.scala b/core/shared/src/main/scala/plotly/layout/Axis.scala index 28c9271..21fb2c8 100755 --- a/core/shared/src/main/scala/plotly/layout/Axis.scala +++ b/core/shared/src/main/scala/plotly/layout/Axis.scala @@ -1,129 +1,129 @@ package plotly package layout -import java.lang.{ Integer => JInt, Double => JDouble, Boolean => JBoolean } +import java.lang.{Boolean => JBoolean, Double => JDouble, Integer => JInt} import dataclass.data import plotly.element._ @data(optionSetters = true) class Axis( - title: Option[String] = None, - titlefont: Option[Font] = None, - showgrid: Option[Boolean] = None, - gridwidth: Option[Int] = None, - gridcolor: Option[Color] = None, - showline: Option[Boolean] = None, - showticklabels: Option[Boolean] = None, - linecolor: Option[Color] = None, - linewidth: Option[Int] = None, - autotick: Option[Boolean] = None, - tickcolor: Option[Color] = None, - tickwidth: Option[Int] = None, - tickangle: Option[Double] = None, - dtick: Option[Double] = None, - ticklen: Option[Int] = None, - tickfont: Option[Font] = None, - tickprefix: Option[String] = None, - ticksuffix: Option[String] = None, - zeroline: Option[Boolean] = None, - zerolinewidth: Option[Double] = None, - zerolinecolor: Option[Color] = None, - range: Option[Range] = None, - autorange: Option[Boolean] = None, - ticks: Option[Ticks] = None, - domain: Option[Range] = None, - side: Option[Side] = None, - anchor: Option[AxisAnchor] = None, - `type`: Option[AxisType] = None, - overlaying: Option[AxisAnchor] = None, - position: Option[Double] = None, - tickmode: Option[TickMode] = None, - tickvals: Option[Sequence] = None, - ticktext: Option[Sequence] = None, - nticks: Option[Int] = None, - automargin: Option[Boolean] = None, - @since("0.8.0") - rangeslider: Option[RangeSlider] = None, - @since("0.8.2") - width: Option[Int] = None, - height: Option[Int] = None, - autosize: Option[Boolean] = None + title: Option[String] = None, + titlefont: Option[Font] = None, + showgrid: Option[Boolean] = None, + gridwidth: Option[Int] = None, + gridcolor: Option[Color] = None, + showline: Option[Boolean] = None, + showticklabels: Option[Boolean] = None, + linecolor: Option[Color] = None, + linewidth: Option[Int] = None, + autotick: Option[Boolean] = None, + tickcolor: Option[Color] = None, + tickwidth: Option[Int] = None, + tickangle: Option[Double] = None, + dtick: Option[Double] = None, + ticklen: Option[Int] = None, + tickfont: Option[Font] = None, + tickprefix: Option[String] = None, + ticksuffix: Option[String] = None, + zeroline: Option[Boolean] = None, + zerolinewidth: Option[Double] = None, + zerolinecolor: Option[Color] = None, + range: Option[Range] = None, + autorange: Option[Boolean] = None, + ticks: Option[Ticks] = None, + domain: Option[Range] = None, + side: Option[Side] = None, + anchor: Option[AxisAnchor] = None, + `type`: Option[AxisType] = None, + overlaying: Option[AxisAnchor] = None, + position: Option[Double] = None, + tickmode: Option[TickMode] = None, + tickvals: Option[Sequence] = None, + ticktext: Option[Sequence] = None, + nticks: Option[Int] = None, + automargin: Option[Boolean] = None, + @since("0.8.0") + rangeslider: Option[RangeSlider] = None, + @since("0.8.2") + width: Option[Int] = None, + height: Option[Int] = None, + autosize: Option[Boolean] = None ) object Axis { @deprecated("Use Axis() and chain-call .with* methods on it instead", "0.8.0") def apply( - title: String = null, - titlefont: Font = null, - showgrid: JBoolean = null, - gridwidth: JInt = null, - gridcolor: Color = null, - showline: JBoolean = null, - showticklabels: JBoolean = null, - linecolor: Color = null, - linewidth: JInt = null, - autotick: JBoolean = null, - tickcolor: Color = null, - tickwidth: JInt = null, - tickangle: JDouble = null, - dtick: JDouble = null, - ticklen: JInt = null, - tickfont: Font = null, - tickprefix: String = null, - ticksuffix: String = null, - zeroline: JBoolean = null, - zerolinewidth: JDouble = null, - zerolinecolor: Color = null, - range: (Double, Double) = null, - autorange: JBoolean = null, - ticks: Ticks = null, - domain: (Double, Double) = null, - side: Side = null, - anchor: AxisAnchor = null, - `type`: AxisType = null, - overlaying: AxisAnchor = null, - position: JDouble = null, - tickmode: TickMode = null, - tickvals: Sequence = null, - ticktext: Sequence = null, - nticks: JInt = null, - automargin: JBoolean = null + title: String = null, + titlefont: Font = null, + showgrid: JBoolean = null, + gridwidth: JInt = null, + gridcolor: Color = null, + showline: JBoolean = null, + showticklabels: JBoolean = null, + linecolor: Color = null, + linewidth: JInt = null, + autotick: JBoolean = null, + tickcolor: Color = null, + tickwidth: JInt = null, + tickangle: JDouble = null, + dtick: JDouble = null, + ticklen: JInt = null, + tickfont: Font = null, + tickprefix: String = null, + ticksuffix: String = null, + zeroline: JBoolean = null, + zerolinewidth: JDouble = null, + zerolinecolor: Color = null, + range: (Double, Double) = null, + autorange: JBoolean = null, + ticks: Ticks = null, + domain: (Double, Double) = null, + side: Side = null, + anchor: AxisAnchor = null, + `type`: AxisType = null, + overlaying: AxisAnchor = null, + position: JDouble = null, + tickmode: TickMode = null, + tickvals: Sequence = null, + ticktext: Sequence = null, + nticks: JInt = null, + automargin: JBoolean = null ): Axis = Axis( Option(title), Option(titlefont), - Option(showgrid) .map(x => x: Boolean), - Option(gridwidth) .map(x => x: Int), + Option(showgrid).map(x => x: Boolean), + Option(gridwidth).map(x => x: Int), Option(gridcolor), - Option(showline) .map(x => x: Boolean), - Option(showticklabels) .map(x => x: Boolean), + Option(showline).map(x => x: Boolean), + Option(showticklabels).map(x => x: Boolean), Option(linecolor), - Option(linewidth) .map(x => x: Int), - Option(autotick) .map(x => x: Boolean), + Option(linewidth).map(x => x: Int), + Option(autotick).map(x => x: Boolean), Option(tickcolor), - Option(tickwidth) .map(x => x: Int), - Option(tickangle) .map(x => x: Double), - Option(dtick) .map(x => x: Double), - Option(ticklen) .map(x => x: Int), + Option(tickwidth).map(x => x: Int), + Option(tickangle).map(x => x: Double), + Option(dtick).map(x => x: Double), + Option(ticklen).map(x => x: Int), Option(tickfont), Option(tickprefix), Option(ticksuffix), - Option(zeroline) .map(x => x: Boolean), - Option(zerolinewidth) .map(x => x: Double), + Option(zeroline).map(x => x: Boolean), + Option(zerolinewidth).map(x => x: Double), Option(zerolinecolor), - Option(range) .map(x => x: Range), - Option(autorange) .map(x => x: Boolean), + Option(range).map(x => x: Range), + Option(autorange).map(x => x: Boolean), Option(ticks), - Option(domain) .map(x => x: Range), + Option(domain).map(x => x: Range), Option(side), Option(anchor), Option(`type`), Option(overlaying), - Option(position) .map(x => x: Double), + Option(position).map(x => x: Double), Option(tickmode), Option(tickvals), Option(ticktext), - Option(nticks) .map(x => x: Int), - Option(automargin) .map(x => x: Boolean) + Option(nticks).map(x => x: Int), + Option(automargin).map(x => x: Boolean) ) } diff --git a/core/shared/src/main/scala/plotly/layout/BarMode.scala b/core/shared/src/main/scala/plotly/layout/BarMode.scala index 065369b..1d58c82 100644 --- a/core/shared/src/main/scala/plotly/layout/BarMode.scala +++ b/core/shared/src/main/scala/plotly/layout/BarMode.scala @@ -4,8 +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") -} \ No newline at end of file +} diff --git a/core/shared/src/main/scala/plotly/layout/Font.scala b/core/shared/src/main/scala/plotly/layout/Font.scala index 716c9b2..30789cd 100644 --- a/core/shared/src/main/scala/plotly/layout/Font.scala +++ b/core/shared/src/main/scala/plotly/layout/Font.scala @@ -1,15 +1,15 @@ package plotly package layout -import java.lang.{ Integer => JInt } +import java.lang.{Integer => JInt} import dataclass.data import plotly.element._ @data(optionSetters = true) class Font( size: Option[Int] = None, - family: Option[String] = None, - color: Option[Color] = None + family: Option[String] = None, + color: Option[Color] = None ) object Font { @@ -28,9 +28,9 @@ object Font { @deprecated("Use Font() and chain-call .with* methods on it instead", "0.8.0") def apply( - size: JInt = null, - family: String = null, - color: Color = null + size: JInt = null, + family: String = null, + color: Color = null ): Font = Font( Option(size).map(x => x: Int), diff --git a/core/shared/src/main/scala/plotly/layout/Grid.scala b/core/shared/src/main/scala/plotly/layout/Grid.scala index 077ea11..67c892b 100644 --- a/core/shared/src/main/scala/plotly/layout/Grid.scala +++ b/core/shared/src/main/scala/plotly/layout/Grid.scala @@ -3,9 +3,9 @@ package plotly.layout import dataclass.data @data(optionSetters = true) class Grid( - rows: Option[Int] = None, - columns: Option[Int] = None, - pattern: Option[Pattern] = None, - roworder: Option[RowOrder] = None, - subplots: Option[Seq[Seq[String]]] = None + rows: Option[Int] = None, + columns: Option[Int] = None, + pattern: Option[Pattern] = None, + roworder: Option[RowOrder] = None, + subplots: Option[Seq[Seq[String]]] = None ) diff --git a/core/shared/src/main/scala/plotly/layout/Layout.scala b/core/shared/src/main/scala/plotly/layout/Layout.scala index 76357d2..4dbcf70 100644 --- a/core/shared/src/main/scala/plotly/layout/Layout.scala +++ b/core/shared/src/main/scala/plotly/layout/Layout.scala @@ -1,76 +1,76 @@ package plotly package layout -import java.lang.{ Integer => JInt, Double => JDouble, Boolean => JBoolean } +import java.lang.{Boolean => JBoolean, Double => JDouble, Integer => JInt} import dataclass.data import plotly.element._ @data(optionSetters = true) class Layout( - title: Option[String] = None, - legend: Option[Legend] = None, - width: Option[Int] = None, - height: Option[Int] = None, - showlegend: Option[Boolean] = None, - xaxis: Option[Axis] = None, - yaxis: Option[Axis] = None, - xaxis1: Option[Axis] = None, - xaxis2: Option[Axis] = None, - xaxis3: Option[Axis] = None, - xaxis4: Option[Axis] = None, - yaxis1: Option[Axis] = None, - yaxis2: Option[Axis] = None, - yaxis3: Option[Axis] = None, - yaxis4: Option[Axis] = None, - barmode: Option[BarMode] = None, - autosize: Option[Boolean] = None, - margin: Option[Margin] = None, + title: Option[String] = None, + legend: Option[Legend] = None, + width: Option[Int] = None, + height: Option[Int] = None, + showlegend: Option[Boolean] = None, + xaxis: Option[Axis] = None, + yaxis: Option[Axis] = None, + xaxis1: Option[Axis] = None, + xaxis2: Option[Axis] = None, + xaxis3: Option[Axis] = None, + xaxis4: Option[Axis] = None, + yaxis1: Option[Axis] = None, + yaxis2: Option[Axis] = None, + yaxis3: Option[Axis] = None, + yaxis4: Option[Axis] = None, + barmode: Option[BarMode] = None, + autosize: Option[Boolean] = None, + margin: Option[Margin] = None, annotations: Option[Seq[Annotation]] = None, - plot_bgcolor: Option[Color] = None, - paper_bgcolor: Option[Color] = None, - font: Option[Font] = None, - bargap: Option[Double] = None, + plot_bgcolor: Option[Color] = None, + paper_bgcolor: Option[Color] = None, + font: Option[Font] = None, + bargap: Option[Double] = None, bargroupgap: Option[Double] = None, - hovermode: Option[HoverMode] = None, - boxmode: Option[BoxMode] = None, - scene: Option[Scene] = None, - @since("0.8.0") - dragmode: Option[String] = None, - shapes: Option[Seq[Shape]] = None, - @since("0.8.2") - grid: Option[Grid] = None + hovermode: Option[HoverMode] = None, + boxmode: Option[BoxMode] = None, + scene: Option[Scene] = None, + @since("0.8.0") + dragmode: Option[String] = None, + shapes: Option[Seq[Shape]] = None, + @since("0.8.2") + grid: Option[Grid] = None ) object Layout { @deprecated("Use Layout() and chain-call .with* methods on it instead", "0.8.0") def apply( - title: String = null, - legend: Legend = null, - width: JInt = null, - height: JInt = null, - showlegend: JBoolean = null, - xaxis: Axis = null, - yaxis: Axis = null, - xaxis1: Axis = null, - xaxis2: Axis = null, - xaxis3: Axis = null, - xaxis4: Axis = null, - yaxis1: Axis = null, - yaxis2: Axis = null, - yaxis3: Axis = null, - yaxis4: Axis = null, - barmode: BarMode = null, - autosize: JBoolean = null, - margin: Margin = null, + title: String = null, + legend: Legend = null, + width: JInt = null, + height: JInt = null, + showlegend: JBoolean = null, + xaxis: Axis = null, + yaxis: Axis = null, + xaxis1: Axis = null, + xaxis2: Axis = null, + xaxis3: Axis = null, + xaxis4: Axis = null, + yaxis1: Axis = null, + yaxis2: Axis = null, + yaxis3: Axis = null, + yaxis4: Axis = null, + barmode: BarMode = null, + autosize: JBoolean = null, + margin: Margin = null, annotations: Seq[Annotation] = null, - plot_bgcolor: Color = null, - paper_bgcolor: Color = null, - font: Font = null, - bargap: JDouble = null, - bargroupgap: JDouble = null, - hovermode: HoverMode = null, - boxmode: BoxMode = null, - scene: Scene = null + plot_bgcolor: Color = null, + paper_bgcolor: Color = null, + font: Font = null, + bargap: JDouble = null, + bargroupgap: JDouble = null, + hovermode: HoverMode = null, + boxmode: BoxMode = null, + scene: Scene = null ): Layout = new Layout( Option(title), diff --git a/core/shared/src/main/scala/plotly/layout/Legend.scala b/core/shared/src/main/scala/plotly/layout/Legend.scala index fcf23d9..daac773 100644 --- a/core/shared/src/main/scala/plotly/layout/Legend.scala +++ b/core/shared/src/main/scala/plotly/layout/Legend.scala @@ -1,38 +1,38 @@ package plotly package layout -import java.lang.{ Double => JDouble } +import java.lang.{Double => JDouble} import dataclass._ import plotly.element._ @data(optionSetters = true) class Legend( - x: Option[Double] = None, - y: Option[Double] = None, - traceorder: Option[TraceOrder] = None, - yref: Option[Ref] = None, - font: Option[Font] = None, - bordercolor: Option[Color] = None, - bgcolor: Option[Color] = None, - xanchor: Option[Anchor] = None, - yanchor: Option[Anchor] = None, - @since - orientation: Option[Orientation] = None + x: Option[Double] = None, + y: Option[Double] = None, + traceorder: Option[TraceOrder] = None, + yref: Option[Ref] = None, + font: Option[Font] = None, + bordercolor: Option[Color] = None, + bgcolor: Option[Color] = None, + xanchor: Option[Anchor] = None, + yanchor: Option[Anchor] = None, + @since + orientation: Option[Orientation] = None ) object Legend { @deprecated("Use Legend() and chain-call .with* methods on it instead", "0.8.0") def apply( - x: JDouble = null, - y: JDouble = null, - traceorder: TraceOrder = null, - yref: Ref = null, - font: Font = null, - bordercolor: Color = null, - bgcolor: Color = null, - xanchor: Anchor = null, - yanchor: Anchor = null, - orientation: Orientation= null + x: JDouble = null, + y: JDouble = null, + traceorder: TraceOrder = null, + yref: Ref = null, + font: Font = null, + bordercolor: Color = null, + bgcolor: Color = null, + xanchor: Anchor = null, + yanchor: Anchor = null, + orientation: Orientation = null ): Legend = Legend( Option(x).map(v => v: Double), @@ -46,4 +46,4 @@ object Legend { Option(yanchor), Option(orientation) ) -} \ No newline at end of file +} diff --git a/core/shared/src/main/scala/plotly/layout/Margin.scala b/core/shared/src/main/scala/plotly/layout/Margin.scala index f328c6d..386e4aa 100644 --- a/core/shared/src/main/scala/plotly/layout/Margin.scala +++ b/core/shared/src/main/scala/plotly/layout/Margin.scala @@ -1,16 +1,16 @@ package plotly package layout -import java.lang.{ Integer => JInt, Boolean => JBoolean } +import java.lang.{Boolean => JBoolean, Integer => JInt} import dataclass.data @data(optionSetters = true) class Margin( - autoexpand: Option[Boolean] = None, - l: Option[Int] = None, - r: Option[Int] = None, - t: Option[Int] = None, - b: Option[Int] = None, - pad: Option[Int] = None + autoexpand: Option[Boolean] = None, + l: Option[Int] = None, + r: Option[Int] = None, + t: Option[Int] = None, + b: Option[Int] = None, + pad: Option[Int] = None ) object Margin { @@ -19,12 +19,12 @@ object Margin { @deprecated("Use Margin() and chain-call .with* methods on it instead", "0.8.0") def apply( - autoexpand: JBoolean = null, - l: JInt = null, - r: JInt = null, - t: JInt = null, - b: JInt = null, - pad: JInt = null + autoexpand: JBoolean = null, + l: JInt = null, + r: JInt = null, + t: JInt = null, + b: JInt = null, + pad: JInt = null ): Margin = Margin( Option(autoexpand).map(b => b: Boolean), diff --git a/core/shared/src/main/scala/plotly/layout/Pattern.scala b/core/shared/src/main/scala/plotly/layout/Pattern.scala index af710ea..f778371 100644 --- a/core/shared/src/main/scala/plotly/layout/Pattern.scala +++ b/core/shared/src/main/scala/plotly/layout/Pattern.scala @@ -4,5 +4,5 @@ sealed abstract class Pattern(val label: String) extends Product with Serializab object Pattern { case object Independent extends Pattern("independent") - case object Coupled extends Pattern("coupled") + case object Coupled extends Pattern("coupled") } diff --git a/core/shared/src/main/scala/plotly/layout/RangeSlider.scala b/core/shared/src/main/scala/plotly/layout/RangeSlider.scala index c8abe47..db3af2c 100644 --- a/core/shared/src/main/scala/plotly/layout/RangeSlider.scala +++ b/core/shared/src/main/scala/plotly/layout/RangeSlider.scala @@ -4,5 +4,5 @@ import dataclass.data import plotly.Range @data(optionSetters = true) class RangeSlider( - range: Option[Range] = None + range: Option[Range] = None ) diff --git a/core/shared/src/main/scala/plotly/layout/Ref.scala b/core/shared/src/main/scala/plotly/layout/Ref.scala index bbb30eb..382dbd9 100644 --- a/core/shared/src/main/scala/plotly/layout/Ref.scala +++ b/core/shared/src/main/scala/plotly/layout/Ref.scala @@ -6,6 +6,6 @@ import plotly.element._ sealed abstract class Ref(val label: String) extends Product with Serializable object Ref { - case object Paper extends Ref("paper") + case object Paper extends Ref("paper") case class Axis(underlying: AxisReference) extends Ref(underlying.label) } diff --git a/core/shared/src/main/scala/plotly/layout/Scene.scala b/core/shared/src/main/scala/plotly/layout/Scene.scala index 8f1b993..52ab727 100644 --- a/core/shared/src/main/scala/plotly/layout/Scene.scala +++ b/core/shared/src/main/scala/plotly/layout/Scene.scala @@ -1,23 +1,23 @@ package plotly package layout -import java.lang.{ Integer => JInt, Double => JDouble, Boolean => JBoolean } +import java.lang.{Boolean => JBoolean, Double => JDouble, Integer => JInt} import dataclass.data import plotly.element._ @data(optionSetters = true) class Scene( - xaxis: Option[Axis] = None, - yaxis: Option[Axis] = None, - zaxis: Option[Axis] = None + xaxis: Option[Axis] = None, + yaxis: Option[Axis] = None, + zaxis: Option[Axis] = None ) object Scene { @deprecated("Use Scene() and chain-call .with* methods on it instead", "0.8.0") def apply( - xaxis: Axis = null, - yaxis: Axis = null, - zaxis: Axis = null + xaxis: Axis = null, + yaxis: Axis = null, + zaxis: Axis = null ): Scene = new Scene( Option(xaxis), Option(yaxis), diff --git a/core/shared/src/main/scala/plotly/layout/Shape.scala b/core/shared/src/main/scala/plotly/layout/Shape.scala index c5046bd..c9b4bd2 100644 --- a/core/shared/src/main/scala/plotly/layout/Shape.scala +++ b/core/shared/src/main/scala/plotly/layout/Shape.scala @@ -3,15 +3,15 @@ package plotly.layout import dataclass.data import plotly.element.{Color, Line} -@data(optionSetters = true) class Shape ( - `type`: Option[String] = None, - xref: Option[String] = None, - yref: Option[String] = None, - x0: Option[String] = None, - y0: Option[Double] = None, - x1: Option[String] = None, - y1: Option[Double] = None, - fillcolor: Option[Color] = None, +@data(optionSetters = true) class Shape( + `type`: Option[String] = None, + xref: Option[String] = None, + yref: Option[String] = None, + x0: Option[String] = None, + y0: Option[Double] = None, + x1: Option[String] = None, + y1: Option[Double] = None, + fillcolor: Option[Color] = None, opacity: Option[Double] = None, - line: Option[Line] = None + line: Option[Line] = None ) diff --git a/demo/src/main/scala/plotly/demo/Demo.scala b/demo/src/main/scala/plotly/demo/Demo.scala index fca802a..960f1ef 100755 --- a/demo/src/main/scala/plotly/demo/Demo.scala +++ b/demo/src/main/scala/plotly/demo/Demo.scala @@ -48,14 +48,15 @@ import scalatags.JsDom.all.{area => _, _} def unindent(source: String): String = { - val lines = source.linesIterator.toVector + val lines = source.linesIterator.toVector val nonEmptyLines = lines.filter(_.exists(!_.isSpaceChar)) if (nonEmptyLines.isEmpty) source else { - val dropCount = Stream.from(0) + val dropCount = Stream + .from(0) .takeWhile(idx => nonEmptyLines.forall(_(idx) == nonEmptyLines.head(idx))) .lastOption .fold(0)(_ + 1) @@ -82,10 +83,9 @@ import scalatags.JsDom.all.{area => _, _} h2("Examples"), div( style := "margin-left: 3em;", - demos.map { - case (chartType, chartDemos) => - val chartTypeId0 = chartTypeId(chartType) - a(href := "#" + chartTypeId0, h3(chartType)) + demos.map { case (chartType, chartDemos) => + val chartTypeId0 = chartTypeId(chartType) + a(href := "#" + chartTypeId0, h3(chartType)) } ) ) @@ -97,11 +97,7 @@ import scalatags.JsDom.all.{area => _, _} val chartTypeId0 = chartTypeId(chartType) - val chartTypeElem = h2(id := chartTypeId0, - a(href := "#" + chartTypeId0, - chartType - ) - ) + val chartTypeElem = h2(id := chartTypeId0, a(href := "#" + chartTypeId0, chartType)) mainDiv.appendChild(chartTypeElem.render) @@ -111,23 +107,24 @@ import scalatags.JsDom.all.{area => _, _} val divId = s"demo-${demo.id}" val elem = - div(id := demo.id, `class` := "panel panel-default", - div(`class` := "panel-heading", - a(href := "#" + demo.id, - h4(demo.id) - ) - ), - div(`class` := "panel-body", - div(`class` := "example-code", + div( + id := demo.id, + `class` := "panel panel-default", + div(`class` := "panel-heading", a(href := "#" + demo.id, h4(demo.id))), + div( + `class` := "panel-body", + div( + `class` := "example-code", pre( - code(`class` := "language-scala", - s"""import plotly._ - |import plotly.element._${if (demo.layout == null) "" else "\nimport plotly.layout._"} + code( + `class` := "language-scala", + s"""import plotly._ + |import plotly.element._${if (demo.layout == null) "" else "\nimport plotly.layout._"} """.stripMargin + - unindent(demo.source) + - s""" - | - |Plotly.plot("div-id", data${if (demo.layout == null) "" else ", layout"})""".stripMargin + unindent(demo.source) + + s""" + | + |Plotly.plot("div-id", data${if (demo.layout == null) "" else ", layout"})""".stripMargin ) ) ), diff --git a/demo/src/main/scala/plotly/demo/area/BasicOverlaidAreaChart.scala b/demo/src/main/scala/plotly/demo/area/BasicOverlaidAreaChart.scala index 042a8e1..b458edc 100644 --- a/demo/src/main/scala/plotly/demo/area/BasicOverlaidAreaChart.scala +++ b/demo/src/main/scala/plotly/demo/area/BasicOverlaidAreaChart.scala @@ -7,8 +7,8 @@ import plotly.element.Fill object BasicOverlaidAreaChart extends NoLayoutDemoChart { def plotlyDocUrl = "https://plot.ly/javascript/filled-area-plots/#basic-overlaid-area-chart" - def id = "basic-overlaid-area-chart" - def source = BasicOverlaidAreaChartSource.source + def id = "basic-overlaid-area-chart" + def source = BasicOverlaidAreaChartSource.source // demo source start diff --git a/demo/src/main/scala/plotly/demo/bar/BarChartWithDirectLabels.scala b/demo/src/main/scala/plotly/demo/bar/BarChartWithDirectLabels.scala index 6e2a91e..c80a38e 100644 --- a/demo/src/main/scala/plotly/demo/bar/BarChartWithDirectLabels.scala +++ b/demo/src/main/scala/plotly/demo/bar/BarChartWithDirectLabels.scala @@ -8,8 +8,8 @@ import plotly.layout._ object BarChartWithDirectLabels extends DemoChart { def plotlyDocUrl = "https://plot.ly/javascript/bar-charts/#bar-chart-with-direct-labels" - def id = "bar-chart-with-direct-labels" - def source = BarChartWithDirectLabelsSource.source + def id = "bar-chart-with-direct-labels" + def source = BarChartWithDirectLabelsSource.source // demo source start @@ -32,15 +32,14 @@ object BarChartWithDirectLabels extends DemoChart { val data = Seq(trace1) - val annotations = xValue.zip(yValue).map { - case (x, y) => - Annotation() - .withX(x) - .withY(y) - .withText(y.toString) - .withXanchor(Anchor.Center) - .withYanchor(Anchor.Bottom) - .withShowarrow(false) + val annotations = xValue.zip(yValue).map { case (x, y) => + Annotation() + .withX(x) + .withY(y) + .withText(y.toString) + .withXanchor(Anchor.Center) + .withYanchor(Anchor.Bottom) + .withShowarrow(false) } val layout = Layout() diff --git a/demo/src/main/scala/plotly/demo/bar/BasicBarChart.scala b/demo/src/main/scala/plotly/demo/bar/BasicBarChart.scala index 1d1e29a..99b69ea 100644 --- a/demo/src/main/scala/plotly/demo/bar/BasicBarChart.scala +++ b/demo/src/main/scala/plotly/demo/bar/BasicBarChart.scala @@ -7,8 +7,8 @@ import plotly.element._ object BasicBarChart extends NoLayoutDemoChart { def plotlyDocUrl = "https://plot.ly/javascript/bar-charts/#basic-bar-chart" - def id = "basic-bar-chart" - def source = BasicBarChartSource.source + def id = "basic-bar-chart" + def source = BasicBarChartSource.source // demo source start diff --git a/demo/src/main/scala/plotly/demo/bar/CustomizingIndividualBarColors.scala b/demo/src/main/scala/plotly/demo/bar/CustomizingIndividualBarColors.scala index b8e1c85..c4c6148 100644 --- a/demo/src/main/scala/plotly/demo/bar/CustomizingIndividualBarColors.scala +++ b/demo/src/main/scala/plotly/demo/bar/CustomizingIndividualBarColors.scala @@ -8,13 +8,13 @@ import plotly.layout._ object CustomizingIndividualBarColors extends DemoChart { def plotlyDocUrl = "" - def id = "customizing-individual-bar-colors" - def source = CustomizingIndividualBarColorsSource.source + def id = "customizing-individual-bar-colors" + def source = CustomizingIndividualBarColorsSource.source // demo source start - val defaultColor = Color.RGBA(204,204,204,1) - val highlightColor = Color.RGBA(222,45,38,0.8) + val defaultColor = Color.RGBA(204, 204, 204, 1) + val highlightColor = Color.RGBA(222, 45, 38, 0.8) val trace1 = Bar( Seq("Feature A", "Feature B", "Feature C", "Feature D", "Feature E"), @@ -22,9 +22,15 @@ object CustomizingIndividualBarColors extends DemoChart { ) .withMarker( Marker() - .withColor(Seq( - defaultColor, highlightColor, defaultColor, defaultColor, defaultColor - )) + .withColor( + Seq( + defaultColor, + highlightColor, + defaultColor, + defaultColor, + defaultColor + ) + ) ) val data = Seq(trace1) diff --git a/demo/src/main/scala/plotly/demo/bar/GroupedBarChart.scala b/demo/src/main/scala/plotly/demo/bar/GroupedBarChart.scala index 895d987..dca3637 100644 --- a/demo/src/main/scala/plotly/demo/bar/GroupedBarChart.scala +++ b/demo/src/main/scala/plotly/demo/bar/GroupedBarChart.scala @@ -8,8 +8,8 @@ import plotly.layout._ object GroupedBarChart extends DemoChart { def plotlyDocUrl = "https://plot.ly/javascript/bar-charts/#grouped-bar-chart" - def id = "grouped-bar-chart" - def source = GroupedBarChartSource.source + def id = "grouped-bar-chart" + def source = GroupedBarChartSource.source // demo source start diff --git a/demo/src/main/scala/plotly/demo/bar/WaterfallBarChart.scala b/demo/src/main/scala/plotly/demo/bar/WaterfallBarChart.scala index 44d5a63..27c8c69 100644 --- a/demo/src/main/scala/plotly/demo/bar/WaterfallBarChart.scala +++ b/demo/src/main/scala/plotly/demo/bar/WaterfallBarChart.scala @@ -8,8 +8,8 @@ import plotly.layout.{Annotation, BarMode, Font, Layout} object WaterfallBarChart extends DemoChart { def plotlyDocUrl = "https://plot.ly/javascript/bar-charts/#waterfall-bar-chart" - def id = "waterfall-bar-chart" - def source = WaterfallBarChartSource.source + def id = "waterfall-bar-chart" + def source = WaterfallBarChartSource.source // demo source start @@ -27,7 +27,7 @@ object WaterfallBarChart extends DemoChart { val textList = Seq("$430K", "$260K", "$690K", "$-120K", "$-200K", "$-320K", "$370K") - //Base + // Base val trace1 = Bar(xData, Seq(0, 430, 0, 570, 370, 370, 0)) .withMarker( @@ -35,7 +35,7 @@ object WaterfallBarChart extends DemoChart { .withColor(Color.RGBA(1, 1, 1, 0.0)) ) - //Revenue + // Revenue val trace2 = Bar(xData, Seq(430, 260, 690, 0, 0, 0, 0)) .withMarker( @@ -48,7 +48,7 @@ object WaterfallBarChart extends DemoChart { ) ) - //Cost + // Cost val trace3 = Bar(xData, Seq(0, 0, 0, 120, 200, 320, 0)) .withMarker( @@ -61,12 +61,12 @@ object WaterfallBarChart extends DemoChart { ) ) - //Profit + // Profit val trace4 = Bar(xData, Seq(0, 0, 0, 0, 0, 0, 370)) .withMarker( Marker() - .withColor(Color.RGBA(50,171, 96, 0.7)) + .withColor(Color.RGBA(50, 171, 96, 0.7)) .withLine( Line() .withColor(Color.RGBA(50, 171, 96, 1.0)) @@ -76,20 +76,19 @@ object WaterfallBarChart extends DemoChart { val data = Seq(trace1, trace2, trace3, trace4) - val annotations = xData.zip(yData).zip(textList).map { - case ((x, y), text) => - Annotation() - .withX(x) - .withY(y) - .withText(text) - .withFont( - Font( - family = "Arial", - size = 14, - color = Color.RGBA(245, 246, 249, 1) - ) + val annotations = xData.zip(yData).zip(textList).map { case ((x, y), text) => + Annotation() + .withX(x) + .withY(y) + .withText(text) + .withFont( + Font( + family = "Arial", + size = 14, + color = Color.RGBA(245, 246, 249, 1) ) - .withShowarrow(false) + ) + .withShowarrow(false) } val layout = Layout() diff --git a/demo/src/main/scala/plotly/demo/bubblecharts/HoverOnTextBubbleChart.scala b/demo/src/main/scala/plotly/demo/bubblecharts/HoverOnTextBubbleChart.scala index 225a7f7..b12e665 100644 --- a/demo/src/main/scala/plotly/demo/bubblecharts/HoverOnTextBubbleChart.scala +++ b/demo/src/main/scala/plotly/demo/bubblecharts/HoverOnTextBubbleChart.scala @@ -8,23 +8,30 @@ import plotly.layout.Layout object HoverOnTextBubbleChart extends DemoChart { def plotlyDocUrl = "https://plot.ly/javascript/bubble-charts/#hover-text-on-bubble-charts" - def id = "hover-on-text-bubble-chart" - def source = HoverOnTextBubbleChartSource.source + def id = "hover-on-text-bubble-chart" + def source = HoverOnTextBubbleChartSource.source // demo source start val trace1 = Scatter(Seq(1, 2, 3, 4), Seq(10, 11, 12, 13)) .withText( - Seq("""A - size = 40""", """B - size = 60""", """C - size = 80""", """D - size = 100""") + Seq( + """A + size = 40""", + """B + size = 60""", + """C + size = 80""", + """D + size = 100""" + ) ) .withMode(ScatterMode(ScatterMode.Markers)) .withMarker( Marker() - .withColor(Seq(Color.RGB(93, 164, 214), Color.RGB(255, 144, 14), Color.RGB(44, 160, 101), Color.RGB(255, 65, 54))) + .withColor( + Seq(Color.RGB(93, 164, 214), Color.RGB(255, 144, 14), Color.RGB(44, 160, 101), Color.RGB(255, 65, 54)) + ) .withSize(Seq(40, 60, 80, 100)) ) diff --git a/demo/src/main/scala/plotly/demo/heatmaps/AnnotatedHeatmap.scala b/demo/src/main/scala/plotly/demo/heatmaps/AnnotatedHeatmap.scala index 3a2b7d0..c8cbb03 100755 --- a/demo/src/main/scala/plotly/demo/heatmaps/AnnotatedHeatmap.scala +++ b/demo/src/main/scala/plotly/demo/heatmaps/AnnotatedHeatmap.scala @@ -8,8 +8,8 @@ import plotly.layout._ object AnnotatedHeatmap extends DemoChart { def plotlyDocUrl = "https://plot.ly/javascript/heatmaps/#annotated-heatmap" - def id = "annotated-heatmap" - def source = AnnotatedHeatmapSource.source + def id = "annotated-heatmap" + def source = AnnotatedHeatmapSource.source // demo source start @@ -26,10 +26,12 @@ object AnnotatedHeatmap extends DemoChart { Heatmap(z, x, y) .withShowscale(false) .withColorscale( - ColorScale.CustomScale(Seq( - (0, Color.StringColor("#3D9970")), - (1, Color.StringColor("#001f3f")) - )) + ColorScale.CustomScale( + Seq( + (0, Color.StringColor("#3D9970")), + (1, Color.StringColor("#001f3f")) + ) + ) ) ) @@ -39,7 +41,7 @@ object AnnotatedHeatmap extends DemoChart { .withYaxis(Axis().withTicks(Ticks.Empty).withTicksuffix(" ")) .withAnnotations( for { - (xv, xi) <- x.zipWithIndex; + (xv, xi) <- x.zipWithIndex (yv, yi) <- y.zipWithIndex } yield Annotation() .withX(xv) @@ -53,4 +55,4 @@ object AnnotatedHeatmap extends DemoChart { // demo source end -} \ No newline at end of file +} diff --git a/demo/src/main/scala/plotly/demo/heatmaps/BasicHeatmap.scala b/demo/src/main/scala/plotly/demo/heatmaps/BasicHeatmap.scala index ebb8f91..1d6d61b 100755 --- a/demo/src/main/scala/plotly/demo/heatmaps/BasicHeatmap.scala +++ b/demo/src/main/scala/plotly/demo/heatmaps/BasicHeatmap.scala @@ -7,8 +7,8 @@ import plotly.element._ object BasicHeatmap extends NoLayoutDemoChart { def plotlyDocUrl = "https://plot.ly/javascript/heatmaps/#basic-heatmap" - def id = "basic-heatmap" - def source = BasicHeatmapSource.source + def id = "basic-heatmap" + def source = BasicHeatmapSource.source // demo source start @@ -26,4 +26,4 @@ object BasicHeatmap extends NoLayoutDemoChart { // demo source end -} \ No newline at end of file +} diff --git a/demo/src/main/scala/plotly/demo/heatmaps/CategoricalAxisHeatmap.scala b/demo/src/main/scala/plotly/demo/heatmaps/CategoricalAxisHeatmap.scala index 0de437e..240497b 100755 --- a/demo/src/main/scala/plotly/demo/heatmaps/CategoricalAxisHeatmap.scala +++ b/demo/src/main/scala/plotly/demo/heatmaps/CategoricalAxisHeatmap.scala @@ -7,22 +7,24 @@ import plotly.element._ object CategoricalAxisHeatmap extends NoLayoutDemoChart { def plotlyDocUrl = "https://plot.ly/javascript/heatmaps/#heatmap-with-categorical-axis-labels" - def id = "categorical-axis-heatmap" - def source = CategoricalAxisHeatmapSource.source + def id = "categorical-axis-heatmap" + def source = CategoricalAxisHeatmapSource.source // demo source start val data = Seq( Heatmap() - .withZ(Seq( - Seq(1, null.asInstanceOf[Int], 30, 50, 1), - Seq(20, 1, 60, 80, 30), - Seq(30, 60, 1, -10, 20) - )) + .withZ( + Seq( + Seq(1, null.asInstanceOf[Int], 30, 50, 1), + Seq(20, 1, 60, 80, 30), + Seq(30, 60, 1, -10, 20) + ) + ) .withX(Seq("Monday", "Tuesday", "Wednesday", "Thursday", "Friday")) .withY(Seq("Morning", "Afternoon", "Evening")) ) // demo source end -} \ No newline at end of file +} diff --git a/demo/src/main/scala/plotly/demo/heatmaps/CustomColorScaleHeatmap.scala b/demo/src/main/scala/plotly/demo/heatmaps/CustomColorScaleHeatmap.scala index ed8ecae..5fa21f4 100755 --- a/demo/src/main/scala/plotly/demo/heatmaps/CustomColorScaleHeatmap.scala +++ b/demo/src/main/scala/plotly/demo/heatmaps/CustomColorScaleHeatmap.scala @@ -7,32 +7,36 @@ import plotly.element._ object CustomColorScaleHeatmap extends NoLayoutDemoChart { def plotlyDocUrl = "https://plot.ly/javascript/colorscales/#custom-colorscale-for-contour-plot" - def id = "custom-colorscale-heatmap" - def source = CustomColorScaleHeatmapSource.source + def id = "custom-colorscale-heatmap" + def source = CustomColorScaleHeatmapSource.source // demo source start val data = Seq( Heatmap() - .withZ(Seq( - Seq(10.0, 10.625, 12.5, 15.625, 20.0), - Seq(5.625, 6.25, 8.125, 11.25, 15.625), - Seq(2.5, 3.125, 5.0, 8.125, 12.5), - Seq(0.625, 1.25, 3.125, 6.25, 10.625), - Seq(0.0, 0.625, 2.5, 5.625, 10.0) - )) + .withZ( + Seq( + Seq(10.0, 10.625, 12.5, 15.625, 20.0), + Seq(5.625, 6.25, 8.125, 11.25, 15.625), + Seq(2.5, 3.125, 5.0, 8.125, 12.5), + Seq(0.625, 1.25, 3.125, 6.25, 10.625), + Seq(0.0, 0.625, 2.5, 5.625, 10.0) + ) + ) .withColorscale( - ColorScale.CustomScale(Seq( - (0, Color.RGB(166,206,227)), - (0.25, Color.RGB(31,120,180)), - (0.45, Color.RGB(178,223,138)), - (0.65, Color.RGB(51,160,44)), - (0.85, Color.RGB(251,154,153)), - (1, Color.RGB(227,26,28)) - )) + ColorScale.CustomScale( + Seq( + (0, Color.RGB(166, 206, 227)), + (0.25, Color.RGB(31, 120, 180)), + (0.45, Color.RGB(178, 223, 138)), + (0.65, Color.RGB(51, 160, 44)), + (0.85, Color.RGB(251, 154, 153)), + (1, Color.RGB(227, 26, 28)) + ) + ) ) ) // demo source end -} \ No newline at end of file +} diff --git a/demo/src/main/scala/plotly/demo/horizontalbarcharts/BasicHorizontalBarChart.scala b/demo/src/main/scala/plotly/demo/horizontalbarcharts/BasicHorizontalBarChart.scala index 43334c6..a9d852e 100644 --- a/demo/src/main/scala/plotly/demo/horizontalbarcharts/BasicHorizontalBarChart.scala +++ b/demo/src/main/scala/plotly/demo/horizontalbarcharts/BasicHorizontalBarChart.scala @@ -7,8 +7,8 @@ import plotly.element.Orientation object BasicHorizontalBarChart extends NoLayoutDemoChart { def plotlyDocUrl = "https://plot.ly/javascript/horizontal-bar-charts/#basic-horizontal-bar-chart" - def id = "basic-horizontal-bar-chart" - def source = BasicHorizontalBarChartSource.source + def id = "basic-horizontal-bar-chart" + def source = BasicHorizontalBarChartSource.source // demo source start diff --git a/demo/src/main/scala/plotly/demo/horizontalbarcharts/ColoredBarChart.scala b/demo/src/main/scala/plotly/demo/horizontalbarcharts/ColoredBarChart.scala index 32430ee..ad55631 100644 --- a/demo/src/main/scala/plotly/demo/horizontalbarcharts/ColoredBarChart.scala +++ b/demo/src/main/scala/plotly/demo/horizontalbarcharts/ColoredBarChart.scala @@ -8,8 +8,8 @@ import plotly.layout.{BarMode, Layout} object ColoredBarChart extends DemoChart { def plotlyDocUrl = "https://plot.ly/javascript/horizontal-bar-charts/#colored-bar-chart" - def id = "colored-bar-chart" - def source = ColoredBarChartSource.source + def id = "colored-bar-chart" + def source = ColoredBarChartSource.source // demo source start diff --git a/demo/src/main/scala/plotly/demo/timeseries/TimeSeries.scala b/demo/src/main/scala/plotly/demo/timeseries/TimeSeries.scala index 803a730..6fdced9 100644 --- a/demo/src/main/scala/plotly/demo/timeseries/TimeSeries.scala +++ b/demo/src/main/scala/plotly/demo/timeseries/TimeSeries.scala @@ -6,8 +6,8 @@ import plotly.demo.NoLayoutDemoChart object TimeSeries extends NoLayoutDemoChart { def plotlyDocUrl = "https://plot.ly/javascript/time-series/#date-strings" - def id = "time-series-chart" - def source = TimeSeriesSource.source + def id = "time-series-chart" + def source = TimeSeriesSource.source // demo source start diff --git a/project/Mima.scala b/project/Mima.scala index b7a667b..ba0d0a1 100644 --- a/project/Mima.scala +++ b/project/Mima.scala @@ -1,4 +1,3 @@ - import com.typesafe.tools.mima.core._ import com.typesafe.tools.mima.plugin.MimaPlugin import sbt._ @@ -11,7 +10,7 @@ object Mima { lazy val renderFilters = Def.settings( MimaPlugin.autoImport.mimaBinaryIssueFilters ++= Seq( // users shouln't ever reference those - ProblemFilters.exclude[Problem]("plotly.internals.shaded.*"), + ProblemFilters.exclude[Problem]("plotly.internals.shaded.*") ) ) diff --git a/project/Settings.scala b/project/Settings.scala index 2f413d2..765b1b1 100644 --- a/project/Settings.scala +++ b/project/Settings.scala @@ -1,4 +1,3 @@ - import com.jsuereth.sbtpgp._ import sbt._ import sbt.Keys._ @@ -10,7 +9,7 @@ object Settings { lazy val generateCustomSources = Seq( customSourceGenerators := { val dir = target.value - val f = dir / "Properties.scala" + val f = dir / "Properties.scala" dir.mkdirs() def gitCommit = @@ -26,8 +25,7 @@ object Settings { | val commitHash = "$gitCommit" | |} - """ - .stripMargin + """.stripMargin .getBytes("UTF-8") ) w.close() @@ -41,14 +39,12 @@ object Settings { def process(destDir: File, pathComponents: Seq[String], file: File): Unit = { if (file.isDirectory) { - val destDir0 = destDir / file.getName + val destDir0 = destDir / file.getName val pathComponents0 = pathComponents :+ file.getName for (f <- file.listFiles()) process(destDir0, pathComponents0, f) } else { - val lines = new String(java.nio.file.Files.readAllBytes(file.toPath), "UTF-8") - .linesIterator - .toVector + val lines = new String(java.nio.file.Files.readAllBytes(file.toPath), "UTF-8").linesIterator.toVector val demoLines = lines .dropWhile(!_.contains("demo source start")) @@ -68,8 +64,7 @@ object Settings { | val source = $tq${demoLines.mkString("\n")}$tq | |} - """ - .stripMargin + """.stripMargin .getBytes("UTF-8") ) w.close() @@ -96,7 +91,7 @@ object Settings { lazy val shared = Def.settings( crossScalaVersions := Seq(scala213, scala212), - scalaVersion := scala213, + scalaVersion := scala213, resolvers += "jitpack" at "https://jitpack.io", libraryDependencies ++= { if (isAtLeastScala213.value) Nil @@ -119,17 +114,16 @@ object Settings { val b = new ProcessBuilder(cmd: _*) b.directory(dir) b.inheritIO() - val p = b.start() + val p = b.start() val retCode = p.waitFor() if (retCode != 0) sys.error(s"Command ${cmd.mkString(" ")} failed (return code $retCode)") } - lazy val fetchTestData = { (Test / unmanagedResources) ++= { - val log = streams.value.log - val baseDir = (LocalRootProject / baseDirectory).value + val log = streams.value.log + val baseDir = (LocalRootProject / baseDirectory).value val testsPostsDir = baseDir / "plotly-documentation" / "_posts" if (!testsPostsDir.exists()) gitLock.synchronized { diff --git a/project/WebDeps.scala b/project/WebDeps.scala index b5852d0..f506ae9 100644 --- a/project/WebDeps.scala +++ b/project/WebDeps.scala @@ -1,4 +1,3 @@ - import sbt._ object WebDeps { @@ -8,8 +7,8 @@ object WebDeps { } def bootstrap = "org.webjars.bower" % "bootstrap" % "3.4.1" - def jquery = "org.webjars.bower" % "jquery" % "3.6.3" - def plotlyJs = "org.webjars.bower" % "plotly.js" % Versions.plotlyJs - def prism = "org.webjars.bower" % "prism" % "1.16.0" + def jquery = "org.webjars.bower" % "jquery" % "3.6.3" + def plotlyJs = "org.webjars.bower" % "plotly.js" % Versions.plotlyJs + def prism = "org.webjars.bower" % "prism" % "1.16.0" } diff --git a/render/js/src/main/scala/plotly/Plotly.scala b/render/js/src/main/scala/plotly/Plotly.scala index 205eec2..7e2a91e 100644 --- a/render/js/src/main/scala/plotly/Plotly.scala +++ b/render/js/src/main/scala/plotly/Plotly.scala @@ -55,33 +55,33 @@ object Plotly { @deprecated("Create a Layout and call plot(div, layout) instead", "0.8.0") def plot( - div: String, - title: String = null, - legend: Legend = null, - width: JInt = null, - height: JInt = null, - showlegend: JBoolean = null, - xaxis: Axis = null, - yaxis: Axis = null, - xaxis1: Axis = null, - xaxis2: Axis = null, - xaxis3: Axis = null, - xaxis4: Axis = null, - yaxis1: Axis = null, - yaxis2: Axis = null, - yaxis3: Axis = null, - yaxis4: Axis = null, - barmode: BarMode = null, - autosize: JBoolean = null, - margin: Margin = null, + div: String, + title: String = null, + legend: Legend = null, + width: JInt = null, + height: JInt = null, + showlegend: JBoolean = null, + xaxis: Axis = null, + yaxis: Axis = null, + xaxis1: Axis = null, + xaxis2: Axis = null, + xaxis3: Axis = null, + xaxis4: Axis = null, + yaxis1: Axis = null, + yaxis2: Axis = null, + yaxis3: Axis = null, + yaxis4: Axis = null, + barmode: BarMode = null, + autosize: JBoolean = null, + margin: Margin = null, annotations: Seq[Annotation] = null, - plot_bgcolor: Color = null, - paper_bgcolor: Color = null, - font: Font = null, - bargap: JDouble = null, - bargroupgap: JDouble = null, - hovermode: HoverMode = null, - boxmode: BoxMode = null + plot_bgcolor: Color = null, + paper_bgcolor: Color = null, + font: Font = null, + bargap: JDouble = null, + bargroupgap: JDouble = null, + hovermode: HoverMode = null, + boxmode: BoxMode = null ): Unit = plot( div, @@ -122,33 +122,33 @@ object Plotly { @deprecated("Create a Layout and call plot(div, layout) instead", "0.8.0") def plot( - div: String, - title: String = null, - legend: Legend = null, - width: JInt = null, - height: JInt = null, - showlegend: JBoolean = null, - xaxis: Axis = null, - yaxis: Axis = null, - xaxis1: Axis = null, - xaxis2: Axis = null, - xaxis3: Axis = null, - xaxis4: Axis = null, - yaxis1: Axis = null, - yaxis2: Axis = null, - yaxis3: Axis = null, - yaxis4: Axis = null, - barmode: BarMode = null, - autosize: JBoolean = null, - margin: Margin = null, + div: String, + title: String = null, + legend: Legend = null, + width: JInt = null, + height: JInt = null, + showlegend: JBoolean = null, + xaxis: Axis = null, + yaxis: Axis = null, + xaxis1: Axis = null, + xaxis2: Axis = null, + xaxis3: Axis = null, + xaxis4: Axis = null, + yaxis1: Axis = null, + yaxis2: Axis = null, + yaxis3: Axis = null, + yaxis4: Axis = null, + barmode: BarMode = null, + autosize: JBoolean = null, + margin: Margin = null, annotations: Seq[Annotation] = null, - plot_bgcolor: Color = null, - paper_bgcolor: Color = null, - font: Font = null, - bargap: JDouble = null, - bargroupgap: JDouble = null, - hovermode: HoverMode = null, - boxmode: BoxMode = null + plot_bgcolor: Color = null, + paper_bgcolor: Color = null, + font: Font = null, + bargap: JDouble = null, + bargroupgap: JDouble = null, + hovermode: HoverMode = null, + boxmode: BoxMode = null ): Unit = plot( div, diff --git a/render/jvm/src/main/scala/plotly/Plotly.scala b/render/jvm/src/main/scala/plotly/Plotly.scala index 31a5859..0677a09 100644 --- a/render/jvm/src/main/scala/plotly/Plotly.scala +++ b/render/jvm/src/main/scala/plotly/Plotly.scala @@ -21,7 +21,7 @@ object Plotly { def jsonSnippet(data: Seq[Trace], layout: Layout, config: Config): String = { val json = Json.obj( - "data" -> data.toList.asJson, + "data" -> data.toList.asJson, "layout" -> layout.asJson, "config" -> config.asJson ) @@ -59,7 +59,7 @@ object Plotly { private def readFully(is: InputStream): Array[Byte] = { val buffer = new ByteArrayOutputStream() - val data = Array.ofDim[Byte](16384) + val data = Array.ofDim[Byte](16384) var nRead = is.read(data, 0, data.length) while (nRead != -1) { @@ -77,7 +77,9 @@ object Plotly { def plotlyMinJs: String = { var is: InputStream = null try { - is = getClass.getClassLoader.getResourceAsStream(s"META-INF/resources/webjars/plotly.js/$plotlyVersion/dist/plotly.min.js") + is = getClass.getClassLoader.getResourceAsStream( + s"META-INF/resources/webjars/plotly.js/$plotlyVersion/dist/plotly.min.js" + ) if (is == null) throw new Exception(s"plotly.min.js resource not found") @@ -89,13 +91,13 @@ object Plotly { } def plot( - path: String, - traces: Seq[Trace], - layout: Layout, - config: Config = Config(), - useCdn: Boolean = true, - openInBrowser: Boolean = true, - addSuffixIfExists: Boolean = true + path: String, + traces: Seq[Trace], + layout: Layout, + config: Config = Config(), + useCdn: Boolean = true, + openInBrowser: Boolean = true, + addSuffixIfExists: Boolean = true ): File = { val f0 = new File(path) @@ -103,7 +105,7 @@ object Plotly { val f = if (addSuffixIfExists) { lazy val name = f0.getName - lazy val idx = name.lastIndexOf('.') + lazy val idx = name.lastIndexOf('.') lazy val (prefix, suffixOpt) = if (idx < 0) @@ -184,11 +186,11 @@ object Plotly { implicit class TraceOps(val trace: Trace) extends AnyVal { def plot( - path: String, - layout: Layout, - useCdn: Boolean, - openInBrowser: Boolean, - addSuffixIfExists: Boolean + path: String, + layout: Layout, + useCdn: Boolean, + openInBrowser: Boolean, + addSuffixIfExists: Boolean ): Unit = Plotly.plot( path, @@ -201,36 +203,36 @@ object Plotly { @deprecated("Create a Layout and call plot(path, layout) instead", "0.8.0") def plot( - path: String = "./plot.html", - title: String = null, - legend: Legend = null, - width: JInt = null, - height: JInt = null, - showlegend: JBoolean = null, - xaxis: Axis = null, - yaxis: Axis = null, - xaxis1: Axis = null, - xaxis2: Axis = null, - xaxis3: Axis = null, - xaxis4: Axis = null, - yaxis1: Axis = null, - yaxis2: Axis = null, - yaxis3: Axis = null, - yaxis4: Axis = null, - barmode: BarMode = null, - autosize: JBoolean = null, - margin: Margin = null, - annotations: Seq[Annotation] = null, - plot_bgcolor: Color = null, - paper_bgcolor: Color = null, - font: Font = null, - bargap: JDouble = null, - bargroupgap: JDouble = null, - hovermode: HoverMode = null, - boxmode: BoxMode = null, - useCdn: Boolean = true, - openInBrowser: Boolean = true, - addSuffixIfExists: Boolean = true + path: String = "./plot.html", + title: String = null, + legend: Legend = null, + width: JInt = null, + height: JInt = null, + showlegend: JBoolean = null, + xaxis: Axis = null, + yaxis: Axis = null, + xaxis1: Axis = null, + xaxis2: Axis = null, + xaxis3: Axis = null, + xaxis4: Axis = null, + yaxis1: Axis = null, + yaxis2: Axis = null, + yaxis3: Axis = null, + yaxis4: Axis = null, + barmode: BarMode = null, + autosize: JBoolean = null, + margin: Margin = null, + annotations: Seq[Annotation] = null, + plot_bgcolor: Color = null, + paper_bgcolor: Color = null, + font: Font = null, + bargap: JDouble = null, + bargroupgap: JDouble = null, + hovermode: HoverMode = null, + boxmode: BoxMode = null, + useCdn: Boolean = true, + openInBrowser: Boolean = true, + addSuffixIfExists: Boolean = true ): Unit = plot( path, @@ -268,8 +270,8 @@ object Plotly { ) def plot( - path: String, - layout: Layout + path: String, + layout: Layout ): Unit = plot( path, @@ -282,11 +284,11 @@ object Plotly { implicit class TraceSeqOps(val traces: Seq[Trace]) extends AnyVal { def plot( - path: String, - layout: Layout, - useCdn: Boolean, - openInBrowser: Boolean, - addSuffixIfExists: Boolean + path: String, + layout: Layout, + useCdn: Boolean, + openInBrowser: Boolean, + addSuffixIfExists: Boolean ): Unit = Plotly.plot( path, @@ -299,36 +301,36 @@ object Plotly { @deprecated("Create a Layout and call plot(path, layout) instead", "0.8.0") def plot( - path: String = "./plot.html", - title: String = null, - legend: Legend = null, - width: JInt = null, - height: JInt = null, - showlegend: JBoolean = null, - xaxis: Axis = null, - yaxis: Axis = null, - xaxis1: Axis = null, - xaxis2: Axis = null, - xaxis3: Axis = null, - xaxis4: Axis = null, - yaxis1: Axis = null, - yaxis2: Axis = null, - yaxis3: Axis = null, - yaxis4: Axis = null, - barmode: BarMode = null, - autosize: JBoolean = null, - margin: Margin = null, - annotations: Seq[Annotation] = null, - plot_bgcolor: Color = null, - paper_bgcolor: Color = null, - font: Font = null, - bargap: JDouble = null, - bargroupgap: JDouble = null, - hovermode: HoverMode = null, - boxmode: BoxMode = null, - useCdn: Boolean = true, - openInBrowser: Boolean = true, - addSuffixIfExists: Boolean = true + path: String = "./plot.html", + title: String = null, + legend: Legend = null, + width: JInt = null, + height: JInt = null, + showlegend: JBoolean = null, + xaxis: Axis = null, + yaxis: Axis = null, + xaxis1: Axis = null, + xaxis2: Axis = null, + xaxis3: Axis = null, + xaxis4: Axis = null, + yaxis1: Axis = null, + yaxis2: Axis = null, + yaxis3: Axis = null, + yaxis4: Axis = null, + barmode: BarMode = null, + autosize: JBoolean = null, + margin: Margin = null, + annotations: Seq[Annotation] = null, + plot_bgcolor: Color = null, + paper_bgcolor: Color = null, + font: Font = null, + bargap: JDouble = null, + bargroupgap: JDouble = null, + hovermode: HoverMode = null, + boxmode: BoxMode = null, + useCdn: Boolean = true, + openInBrowser: Boolean = true, + addSuffixIfExists: Boolean = true ): Unit = plot( path, @@ -366,8 +368,8 @@ object Plotly { ) def plot( - path: String, - layout: Layout + path: String, + layout: Layout ): Unit = plot( path, diff --git a/render/jvm/src/main/scala/plotly/internals/Properties.scala b/render/jvm/src/main/scala/plotly/internals/Properties.scala index b8d77b7..a129698 100644 --- a/render/jvm/src/main/scala/plotly/internals/Properties.scala +++ b/render/jvm/src/main/scala/plotly/internals/Properties.scala @@ -8,19 +8,17 @@ object Properties { val p = new JProperties try { p.load( - getClass - .getClassLoader + getClass.getClassLoader .getResourceAsStream("plotly/plotly-scala.properties") ) - } - catch { + } catch { case _: NullPointerException => } p } lazy val plotlyJsVersion = props.getProperty("plotly-js-version") - lazy val version = props.getProperty("version") - lazy val commitHash = props.getProperty("commit-hash") + lazy val version = props.getProperty("version") + lazy val commitHash = props.getProperty("commit-hash") } diff --git a/render/shared/src/main/scala/plotly/Enumerate.scala b/render/shared/src/main/scala/plotly/Enumerate.scala index d701c7a..2f1e97f 100644 --- a/render/shared/src/main/scala/plotly/Enumerate.scala +++ b/render/shared/src/main/scala/plotly/Enumerate.scala @@ -1,6 +1,6 @@ package plotly -import shapeless.{ :+:, ::, CNil, Coproduct, Generic, HList, HNil, Inl, Inr, Strict } +import shapeless.{:+:, ::, CNil, Coproduct, Generic, HList, HNil, Inl, Inr, Strict} sealed abstract class Enumerate[T] { def apply(): Seq[T] @@ -19,11 +19,10 @@ object Enumerate { implicit val hnil: Enumerate[HNil] = instance(Seq(HNil)) - implicit def hcons[H, T <: HList] - (implicit - head: Strict[Enumerate[H]], - tail: Enumerate[T] - ): Enumerate[H :: T] = + implicit def hcons[H, T <: HList](implicit + head: Strict[Enumerate[H]], + tail: Enumerate[T] + ): Enumerate[H :: T] = instance { for { h <- head.value() @@ -33,17 +32,15 @@ object Enumerate { implicit val cnil: Enumerate[CNil] = instance(Seq()) - implicit def ccons[H, T <: Coproduct] - (implicit - head: Strict[Enumerate[H]], - tail: Enumerate[T] - ): Enumerate[H :+: T] = + implicit def ccons[H, T <: Coproduct](implicit + head: Strict[Enumerate[H]], + tail: Enumerate[T] + ): Enumerate[H :+: T] = instance(head.value().map(Inl(_)) ++ tail().map(Inr(_))) - implicit def generic[F, G] - (implicit - gen: Generic.Aux[F, G], - underlying: Strict[Enumerate[G]] - ): Enumerate[F] = + implicit def generic[F, G](implicit + gen: Generic.Aux[F, G], + underlying: Strict[Enumerate[G]] + ): Enumerate[F] = instance(underlying.value().map(gen.from)) } diff --git a/render/shared/src/main/scala/plotly/internals/BetterPrinter.scala b/render/shared/src/main/scala/plotly/internals/BetterPrinter.scala index d3f777a..8012078 100644 --- a/render/shared/src/main/scala/plotly/internals/BetterPrinter.scala +++ b/render/shared/src/main/scala/plotly/internals/BetterPrinter.scala @@ -9,55 +9,70 @@ final case class BetterPrinter(params: PrettyParams) { private def addIndentation(s: String): Int => String = { val lastNewLineIndex = s.lastIndexOf("\n") - if (lastNewLineIndex < 0) { - _ => s + if (lastNewLineIndex < 0) { _ => + s } else { val afterLastNewLineIndex = lastNewLineIndex + 1 - val start = s.substring(0, afterLastNewLineIndex) - val end = s.substring(afterLastNewLineIndex) + val start = s.substring(0, afterLastNewLineIndex) + val end = s.substring(afterLastNewLineIndex) n => start + indent * n + end } } - private val openBraceText = "{" - private val closeBraceText = "}" - private val openArrayText = "[" - private val closeArrayText = "]" - private val commaText = "," - private val colonText = ":" - private val nullText = "null" - private val trueText = "true" - private val falseText = "false" + private val openBraceText = "{" + private val closeBraceText = "}" + private val openArrayText = "[" + private val closeArrayText = "]" + private val commaText = "," + private val colonText = ":" + private val nullText = "null" + private val trueText = "true" + private val falseText = "false" private val stringEnclosureText = "\"" - private val _lbraceLeft = addIndentation(lbraceLeft) - private val _lbraceRight = addIndentation(lbraceRight) - private val _rbraceLeft = addIndentation(rbraceLeft) - private val _rbraceRight = addIndentation(rbraceRight) - private val _lbracketLeft = addIndentation(lbracketLeft) - private val _lbracketRight = addIndentation(lbracketRight) - private val _rbracketLeft = addIndentation(rbracketLeft) - private val _rbracketRight = addIndentation(rbracketRight) - private val _lrbracketsEmpty = addIndentation(lrbracketsEmpty) - private val _arrayCommaLeft = addIndentation(arrayCommaLeft) - private val _arrayCommaRight = addIndentation(arrayCommaRight) - private val _objectCommaLeft = addIndentation(objectCommaLeft) + private val _lbraceLeft = addIndentation(lbraceLeft) + private val _lbraceRight = addIndentation(lbraceRight) + private val _rbraceLeft = addIndentation(rbraceLeft) + private val _rbraceRight = addIndentation(rbraceRight) + private val _lbracketLeft = addIndentation(lbracketLeft) + private val _lbracketRight = addIndentation(lbracketRight) + private val _rbracketLeft = addIndentation(rbracketLeft) + private val _rbracketRight = addIndentation(rbracketRight) + private val _lrbracketsEmpty = addIndentation(lrbracketsEmpty) + private val _arrayCommaLeft = addIndentation(arrayCommaLeft) + private val _arrayCommaRight = addIndentation(arrayCommaRight) + private val _objectCommaLeft = addIndentation(objectCommaLeft) private val _objectCommaRight = addIndentation(objectCommaRight) - private val _colonLeft = addIndentation(colonLeft) - private val _colonRight = addIndentation(colonRight) + private val _colonLeft = addIndentation(colonLeft) + private val _colonRight = addIndentation(colonRight) - private val lbraceMemo = vectorMemo{depth: Int => "%s%s%s".format(_lbraceLeft(depth), openBraceText, _lbraceRight(depth + 1))} - private val rbraceMemo = vectorMemo{depth: Int => "%s%s%s".format(_rbraceLeft(depth), closeBraceText, _rbraceRight(depth + 1))} + private val lbraceMemo = vectorMemo { depth: Int => + "%s%s%s".format(_lbraceLeft(depth), openBraceText, _lbraceRight(depth + 1)) + } + private val rbraceMemo = vectorMemo { depth: Int => + "%s%s%s".format(_rbraceLeft(depth), closeBraceText, _rbraceRight(depth + 1)) + } - private val lbracketMemo = vectorMemo{depth: Int => "%s%s%s".format(_lbracketLeft(depth), openArrayText, _lbracketRight(depth + 1))} - private val rbracketMemo = vectorMemo{depth: Int => "%s%s%s".format(_rbracketLeft(depth), closeArrayText, _rbracketRight(depth))} - private val lrbracketsEmptyMemo = vectorMemo{depth: Int => "%s%s%s".format(openArrayText, _lrbracketsEmpty(depth), closeArrayText)} - private val arrayCommaMemo = vectorMemo{depth: Int => "%s%s%s".format(_arrayCommaLeft(depth + 1), commaText, _arrayCommaRight(depth + 1))} - private val objectCommaMemo = vectorMemo{depth: Int => "%s%s%s".format(_objectCommaLeft(depth + 1), commaText, _objectCommaRight(depth + 1))} - private val colonMemo = vectorMemo{depth: Int => "%s%s%s".format(_colonLeft(depth + 1), colonText, _colonRight(depth + 1))} + private val lbracketMemo = vectorMemo { depth: Int => + "%s%s%s".format(_lbracketLeft(depth), openArrayText, _lbracketRight(depth + 1)) + } + private val rbracketMemo = vectorMemo { depth: Int => + "%s%s%s".format(_rbracketLeft(depth), closeArrayText, _rbracketRight(depth)) + } + private val lrbracketsEmptyMemo = vectorMemo { depth: Int => + "%s%s%s".format(openArrayText, _lrbracketsEmpty(depth), closeArrayText) + } + private val arrayCommaMemo = vectorMemo { depth: Int => + "%s%s%s".format(_arrayCommaLeft(depth + 1), commaText, _arrayCommaRight(depth + 1)) + } + private val objectCommaMemo = vectorMemo { depth: Int => + "%s%s%s".format(_objectCommaLeft(depth + 1), commaText, _objectCommaRight(depth + 1)) + } + private val colonMemo = vectorMemo { depth: Int => + "%s%s%s".format(_colonLeft(depth + 1), colonText, _colonRight(depth + 1)) + } - /** - * Returns a string representation of a pretty-printed JSON value. + /** Returns a string representation of a pretty-printed JSON value. */ def render(j: Json): String = { @@ -107,33 +122,41 @@ final case class BetterPrinter(params: PrettyParams) { } k.fold[StringBuilder]( - builder.append(nullText) - , bool => builder.append(if (bool) trueText else falseText) - , n => n match { - case JsonLong(x) => builder append x.toString - case JsonDecimal(x) => builder append x - case JsonBigDecimal(x) => builder append x.toString - } - , s => encloseJsonString(builder, s) - , e => if (e.isEmpty) { - lrbracketsEmpty(builder) - } else { - rbracket(e.foldLeft((true, lbracket(builder))){case ((firstElement, builder), subElement) => - val withComma = if (firstElement) builder else arrayComma(builder) - val updatedBuilder = trav(withComma, depth + 1, subElement) - (false, updatedBuilder) - }._2) - } - , o => { - rbrace((if (preserveOrder) o.toList else o.toMap).foldLeft((true, lbrace(builder))){case ((firstElement, builder), (key, value)) => - val ignoreKey = dropNullKeys && value.isNull - if (ignoreKey) { - (firstElement, builder) - } else { - val withComma = if (firstElement) builder else objectComma(builder) - (false, trav(colon(encloseJsonString(withComma, key)), depth + 1, value)) - } - }._2) + builder.append(nullText), + bool => builder.append(if (bool) trueText else falseText), + n => + n match { + case JsonLong(x) => builder append x.toString + case JsonDecimal(x) => builder append x + case JsonBigDecimal(x) => builder append x.toString + }, + s => encloseJsonString(builder, s), + e => + if (e.isEmpty) { + lrbracketsEmpty(builder) + } else { + rbracket( + e.foldLeft((true, lbracket(builder))) { case ((firstElement, builder), subElement) => + val withComma = if (firstElement) builder else arrayComma(builder) + val updatedBuilder = trav(withComma, depth + 1, subElement) + (false, updatedBuilder) + }._2 + ) + }, + o => { + rbrace( + (if (preserveOrder) o.toList else o.toMap) + .foldLeft((true, lbrace(builder))) { case ((firstElement, builder), (key, value)) => + val ignoreKey = dropNullKeys && value.isNull + if (ignoreKey) { + (firstElement, builder) + } else { + val withComma = if (firstElement) builder else objectComma(builder) + (false, trav(colon(encloseJsonString(withComma, key)), depth + 1, value)) + } + } + ._2 + ) } ) } diff --git a/tests/src/test/scala/plotly/FieldTests.scala b/tests/src/test/scala/plotly/FieldTests.scala index f3ac881..7bcb80d 100644 --- a/tests/src/test/scala/plotly/FieldTests.scala +++ b/tests/src/test/scala/plotly/FieldTests.scala @@ -10,7 +10,8 @@ class FieldTests extends AnyFlatSpec with Matchers { val expectedField = Json.jBool(true) - val field = Codecs.argonautEncodeTrace(trace) + val field = Codecs + .argonautEncodeTrace(trace) .obj .toList .flatMap(_.toList.filter(_._1 == "showlegend").map(_._2)) diff --git a/tests/src/test/scala/plotly/SequenceTests.scala b/tests/src/test/scala/plotly/SequenceTests.scala index e70e54b..80f4441 100644 --- a/tests/src/test/scala/plotly/SequenceTests.scala +++ b/tests/src/test/scala/plotly/SequenceTests.scala @@ -17,12 +17,12 @@ class SequenceTests extends AnyFlatSpec { it should "convert a nested mutable ArrayBuffer to a Sequence" in { val mutableNestedDoubles: ArrayBuffer[ArrayBuffer[Double]] = ArrayBuffer( ArrayBuffer(1d, 2d), - ArrayBuffer(3d, 4d), + ArrayBuffer(3d, 4d) ) val nestedDoublesList: List[List[Double]] = List( List(1d, 2d), - List(3d, 4d), + List(3d, 4d) ) assert((mutableNestedDoubles: Sequence) === Sequence.NestedDoubles(nestedDoublesList)) diff --git a/tests/src/test/scala/plotly/doc/DocumentationTests.scala b/tests/src/test/scala/plotly/doc/DocumentationTests.scala index b341bc0..c22ceb2 100755 --- a/tests/src/test/scala/plotly/doc/DocumentationTests.scala +++ b/tests/src/test/scala/plotly/doc/DocumentationTests.scala @@ -11,7 +11,7 @@ import org.mozilla.javascript._ import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers import plotly.element.HoverInfo -import plotly.element.HoverInfo.{X,Y,Z} +import plotly.element.HoverInfo.{X, Y, Z} import plotly.element.ColorModel._ import scala.util.matching.Regex @@ -22,7 +22,7 @@ object DocumentationTests { private def readFully(is: InputStream): Array[Byte] = { val buffer = new ByteArrayOutputStream() - val data = Array.ofDim[Byte](16384) + val data = Array.ofDim[Byte](16384) var nRead = is.read(data, 0, data.length) while (nRead != -1) { @@ -34,12 +34,11 @@ object DocumentationTests { buffer.toByteArray } - def load(path: String): String = { - val cl = getClass.getClassLoader // resources should be in the same JAR as this, so same loader + val cl = getClass.getClassLoader // resources should be in the same JAR as this, so same loader val resPath = s"plotly/doc/$path" - val is = cl.getResourceAsStream(resPath) + val is = cl.getResourceAsStream(resPath) if (is == null) throw new NoSuchElementException(s"Resource $resPath") @@ -51,7 +50,7 @@ object DocumentationTests { def resourceTrace(res: String): Trace = { val dataStr = load(res) - val result = dataStr.decodeEither[Trace] + val result = dataStr.decodeEither[Trace] result.getOrElse { throw new Exception(s"$res: $result") } @@ -59,7 +58,7 @@ object DocumentationTests { def resourceLayout(res: String): Layout = { val dataStr = load(res) - val result = dataStr.decodeEither[Layout] + val result = dataStr.decodeEither[Layout] result.getOrElse { throw new Exception(s"$res: $result") } @@ -67,7 +66,7 @@ object DocumentationTests { private class Plotly extends plotly.doc.Plotly { - var dataOpt = Option.empty[Object] + var dataOpt = Option.empty[Object] var layoutOpt = Option.empty[Object] def newPlot(div: String, data: Object, layout: Object, other: Object): Unit = { @@ -95,9 +94,13 @@ object DocumentationTests { def jsonRepr(obj: Object): Json = { val jsonStr = stringify(obj) - Parse.parse(jsonStr).left.map { err => - throw new Exception(s"Cannot parse JSON: $err\n$jsonStr") - }.merge + Parse + .parse(jsonStr) + .left + .map { err => + throw new Exception(s"Cannot parse JSON: $err\n$jsonStr") + } + .merge } val data = dataOpt.map(jsonRepr) match { @@ -143,7 +146,7 @@ object DocumentationTests { def requireImpl(cx: Context, thisObj: Scriptable, args: Array[Object], funObj: Function): AnyRef = args match { case Array("linspace") => linspace(thisObj) - case other => throw new NoSuchElementException(s"require${other.mkString("(", ", ", ")")}") + case other => throw new NoSuchElementException(s"require${other.mkString("(", ", ", ")")}") } private def linspace(scope: Scriptable) = new FunctionObject( @@ -164,28 +167,28 @@ object DocumentationTests { val cx = Context.enter() - val (rawDataElems, rawLayoutOpt) = try { - val scope = cx.initStandardObjects() - ScriptableObject.putProperty(scope, "Plotly", plotly) - ScriptableObject.putProperty(scope, "document", Document) - ScriptableObject.putProperty(scope, "numeric", Numeric) - ScriptableObject.putProperty(scope, "require", require(scope)) - ScriptableObject.putProperty(scope, "linspace", linspace(scope)) - cx.evaluateString(scope, demo, "", 1, null) - plotly.result(cx, scope) - } catch { - case e: org.mozilla.javascript.EvaluatorException => - println(s"Was running\n$demo\n\n") - throw new Exception(s"Evaluation error at line ${e.lineNumber()} column ${e.columnNumber()}", e) - } finally { - Context.exit() - } + val (rawDataElems, rawLayoutOpt) = + try { + val scope = cx.initStandardObjects() + ScriptableObject.putProperty(scope, "Plotly", plotly) + ScriptableObject.putProperty(scope, "document", Document) + ScriptableObject.putProperty(scope, "numeric", Numeric) + ScriptableObject.putProperty(scope, "require", require(scope)) + ScriptableObject.putProperty(scope, "linspace", linspace(scope)) + cx.evaluateString(scope, demo, "", 1, null) + plotly.result(cx, scope) + } catch { + case e: org.mozilla.javascript.EvaluatorException => + println(s"Was running\n$demo\n\n") + throw new Exception(s"Evaluation error at line ${e.lineNumber()} column ${e.columnNumber()}", e) + } finally { + Context.exit() + } val decodeData0 = rawDataElems.map(json => json -> json.as[Trace].toEither) - val dataErrors = decodeData0.collect { - case (json, Left((err, h))) => - (json, err, h) + val dataErrors = decodeData0.collect { case (json, Left((err, h))) => + (json, err, h) } if (dataErrors.nonEmpty) { @@ -195,8 +198,8 @@ object DocumentationTests { throw new Exception("Error decoding data (see above messages)") } - val data = decodeData0.collect { - case (_, Right(data)) => data + val data = decodeData0.collect { case (_, Right(data)) => + data } val decodeLayoutOpt = rawLayoutOpt.map(json => json -> json.as[Layout].toEither) @@ -279,7 +282,7 @@ class DocumentationTests extends AnyFlatSpec with Matchers { for { subDir <- subDirs - post <- subDir.listFiles().sorted + post <- subDir.listFiles().sorted if !post.getName.startsWith(".") } { s"$subDir" should s"$post" in { @@ -289,18 +292,19 @@ class DocumentationTests extends AnyFlatSpec with Matchers { .replace("
", "\\n") .replace("(...size)", "(size[0])") // rhino doesn't seem to support the spead (...) operator .replace("desired_maximum_marker_size**2", "desired_maximum_marker_size*desired_maximum_marker_size") - .replace("""function linspace(a,b,n) { + .replace( + """function linspace(a,b,n) { return Plotly.d3.range(n).map(function(i){return a+i*(b-a)/(n-1);}); } -""", "") +""", + "" + ) if (content.contains("Plotly.d3.csv")) println(s"Ignoring $post (Plotly.d3.csv not implemented)") else { - val lines = content - .linesIterator - .toVector + val lines = content.linesIterator.toVector .map(_.trim) .filter(_.nonEmpty) @@ -334,17 +338,19 @@ class DocumentationTests extends AnyFlatSpec with Matchers { |Plotly.newPlot('myDiv', data, layout); |""".stripMargin val (data, maybeLayout) = plotlyDemoElements(js) - maybeLayout should ===(Some( - Layout() - .withWidth(400) - .withHeight(400) - .withTitle("image with opacity 0.1") - )) + maybeLayout should ===( + Some( + Layout() + .withWidth(400) + .withHeight(400) + .withTitle("image with opacity 0.1") + ) + ) data.headOption match { case Some(image) => val colors = Seq( - Seq(Seq(255d, 0d, 0d), Seq(0d, 255, 0), Seq(0d, 0, 255)), + Seq(Seq(255d, 0d, 0d), Seq(0d, 255, 0), Seq(0d, 0, 255)) ) val expected = Image(z = colors) .withOpacity(0.1) diff --git a/tests/src/test/scala/plotly/doc/SchemaTests.scala b/tests/src/test/scala/plotly/doc/SchemaTests.scala index a1b09be..a865475 100644 --- a/tests/src/test/scala/plotly/doc/SchemaTests.scala +++ b/tests/src/test/scala/plotly/doc/SchemaTests.scala @@ -19,17 +19,17 @@ object SchemaTests { case class ConstantString(value: String) extends Attribute case class Flag( - valType: Witness.`"flaglist"`.T, - flags: List[String], - description: String, - role: String + valType: Witness.`"flaglist"`.T, + flags: List[String], + description: String, + role: String ) extends Attribute case class Enumerated( - valType: Witness.`"enumerated"`.T, - description: String, - role: String, - values: List[String] + valType: Witness.`"enumerated"`.T, + description: String, + role: String, + values: List[String] ) extends Attribute case class Other(json: Json) extends Attribute @@ -37,11 +37,12 @@ object SchemaTests { implicit val decode: DecodeJson[Attribute] = DecodeJson { c => val constantString = c.as[String].map[Attribute](ConstantString(_)) - def flag = c.as[Flag].map[Attribute](x => x) - def enumerated = c.as[Enumerated].map[Attribute](x => x) - def other = DecodeResult.ok[Attribute](Other(c.focus)) + def flag = c.as[Flag].map[Attribute](x => x) + def enumerated = c.as[Enumerated].map[Attribute](x => x) + def other = DecodeResult.ok[Attribute](Other(c.focus)) - constantString.toOption.map(DecodeResult.ok) + constantString.toOption + .map(DecodeResult.ok) .orElse(flag.toOption.map(DecodeResult.ok)) .orElse(enumerated.toOption.map(DecodeResult.ok)) .getOrElse(other) @@ -49,8 +50,8 @@ object SchemaTests { } case class Trace( - description: Option[String], - attributes: Map[String, Attribute] + description: Option[String], + attributes: Map[String, Attribute] ) { def flagAttribute(name: String): Attribute.Flag = attributes.get(name) match { @@ -74,7 +75,7 @@ object SchemaTests { } case class Schema( - traces: Map[String, Trace] + traces: Map[String, Trace] ) val schemaFile = new File("plotly-documentation/_data/plotschema.json") @@ -104,7 +105,7 @@ class SchemaTests extends AnyFlatSpec with Matchers { private def compareValues(fromSchema: Set[String], fromLib: Set[String]): Unit = { val onlySchema = (fromSchema -- fromLib).toVector.sorted - val onlyLib = (fromLib -- fromSchema).toVector.sorted + val onlyLib = (fromLib -- fromSchema).toVector.sorted assert(onlySchema.isEmpty, s"Only in schema: ${onlySchema.mkString(", ")}") assert(onlyLib.isEmpty, s"Only in lib: ${onlyLib.mkString(", ")}") @@ -131,7 +132,8 @@ class SchemaTests extends AnyFlatSpec with Matchers { .values .toSet - val fromLib = Enumerate[TextPosition].apply() + val fromLib = Enumerate[TextPosition] + .apply() .map(_.label) .toSet @@ -139,4 +141,3 @@ class SchemaTests extends AnyFlatSpec with Matchers { } } - diff --git a/tests/src/test/scala/plotly/element/LocalDateTimeTests.scala b/tests/src/test/scala/plotly/element/LocalDateTimeTests.scala index 8328a11..251305f 100644 --- a/tests/src/test/scala/plotly/element/LocalDateTimeTests.scala +++ b/tests/src/test/scala/plotly/element/LocalDateTimeTests.scala @@ -7,35 +7,35 @@ import plotly.element.{LocalDateTime => PlotlyLocalDateTime} class LocalDateTimeTests extends AnyFlatSpec { "JavaTime conversions" should "convert java.time.LocalDateTime to Plotly LocalDateTime" in { - val javaLocalDateTime = java.time.LocalDateTime.parse("2020-04-18T14:52:52") + val javaLocalDateTime = java.time.LocalDateTime.parse("2020-04-18T14:52:52") val plotlyLocalDateTime = PlotlyLocalDateTime(2020, 4, 18, 14, 52, 52) assert((javaLocalDateTime: PlotlyLocalDateTime) === plotlyLocalDateTime) } it should "convert java.time.Instant to Plotly LocalDateTime using UTC" in { - val javaInstant = java.time.Instant.parse("2020-04-18T14:52:52Z") + val javaInstant = java.time.Instant.parse("2020-04-18T14:52:52Z") val plotlyLocalDateTime = PlotlyLocalDateTime(2020, 4, 18, 14, 52, 52) assert((javaInstant: PlotlyLocalDateTime) === plotlyLocalDateTime) } it should "convert java.time.OffsetDateTime to Plotly LocalDateTime" in { - val javaOffsetDateTime = java.time.OffsetDateTime.parse("2020-04-18T14:52:52+10:00") + val javaOffsetDateTime = java.time.OffsetDateTime.parse("2020-04-18T14:52:52+10:00") val plotlyLocalDateTime = PlotlyLocalDateTime(2020, 4, 18, 14, 52, 52) assert((javaOffsetDateTime: PlotlyLocalDateTime) === plotlyLocalDateTime) } it should "convert java.time.ZonedDateTime to Plotly LocalDateTime" in { - val javaOffsetDateTime = java.time.ZonedDateTime.parse("2020-04-18T14:52:52+10:00[Australia/Melbourne]") + val javaOffsetDateTime = java.time.ZonedDateTime.parse("2020-04-18T14:52:52+10:00[Australia/Melbourne]") val plotlyLocalDateTime = PlotlyLocalDateTime(2020, 4, 18, 14, 52, 52) assert((javaOffsetDateTime: PlotlyLocalDateTime) === plotlyLocalDateTime) } it should "convert java.time.LocalDate to Plotly LocalDateTime" in { - val javaLocalDate = java.time.LocalDate.parse("2020-04-18") + val javaLocalDate = java.time.LocalDate.parse("2020-04-18") val plotlyLocalDateTime = PlotlyLocalDateTime(2020, 4, 18, 0, 0, 0) assert((javaLocalDate: PlotlyLocalDateTime) === plotlyLocalDateTime) From 42ffa6267b11879506389222c7b0292ac0999fb1 Mon Sep 17 00:00:00 2001 From: Sven Behrens Date: Tue, 30 Apr 2024 09:06:08 +0200 Subject: [PATCH 7/7] Add properties Histogram.{yaxis, hovertext}, layout.Axis.{tickformat, fixedrange} and add Demo for Histogram --- .git-blame-ignore-revs | 5 ++ core/shared/src/main/scala/plotly/Trace.scala | 5 +- .../src/main/scala/plotly/layout/Axis.scala | 5 +- demo/src/main/scala/plotly/demo/Demo.scala | 14 ++-- .../demo/histogram/BasicHistogram.scala | 31 ++++++++ .../demo/histogram/StyledBasicHistogram.scala | 46 +++++++++++ project/Deps.scala | 17 ++-- render/js/src/main/scala/plotly/Plotly.scala | 77 ++++++++++++------- 8 files changed, 154 insertions(+), 46 deletions(-) create mode 100644 .git-blame-ignore-revs create mode 100644 demo/src/main/scala/plotly/demo/histogram/BasicHistogram.scala create mode 100644 demo/src/main/scala/plotly/demo/histogram/StyledBasicHistogram.scala diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 0000000..be28ae1 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,5 @@ +# activate meaningful git annotations with: +# git config blame.ignoreRevsFile .git-blame-ignore-revs + +# scalafmt +0ad886c35bdf9c8ad2bfb0501070b8b2ce810710 diff --git a/core/shared/src/main/scala/plotly/Trace.scala b/core/shared/src/main/scala/plotly/Trace.scala index f2823f6..a8a8d03 100755 --- a/core/shared/src/main/scala/plotly/Trace.scala +++ b/core/shared/src/main/scala/plotly/Trace.scala @@ -251,7 +251,10 @@ object Bar { cumulative: Option[Cumulative] = None, histfunc: Option[HistFunc] = None, @since("0.8.2") - hovertemplate: Option[OneOrSeq[String]] = None + hovertemplate: Option[OneOrSeq[String]] = None, + @since("0.8.5") + yaxis: Option[String] = None, + hovertext: Option[OneOrSeq[String]] = None ) extends Trace object Histogram { diff --git a/core/shared/src/main/scala/plotly/layout/Axis.scala b/core/shared/src/main/scala/plotly/layout/Axis.scala index 21fb2c8..b6c0bf2 100755 --- a/core/shared/src/main/scala/plotly/layout/Axis.scala +++ b/core/shared/src/main/scala/plotly/layout/Axis.scala @@ -47,7 +47,10 @@ import plotly.element._ @since("0.8.2") width: Option[Int] = None, height: Option[Int] = None, - autosize: Option[Boolean] = None + autosize: Option[Boolean] = None, + @since("0.8.5") + tickformat: Option[String] = None, + fixedrange: Option[Boolean] = None ) object Axis { diff --git a/demo/src/main/scala/plotly/demo/Demo.scala b/demo/src/main/scala/plotly/demo/Demo.scala index 960f1ef..dbca596 100755 --- a/demo/src/main/scala/plotly/demo/Demo.scala +++ b/demo/src/main/scala/plotly/demo/Demo.scala @@ -43,21 +43,25 @@ import scalatags.JsDom.all.{area => _, _} heatmaps.CategoricalAxisHeatmap, heatmaps.CustomColorScaleHeatmap, heatmaps.AnnotatedHeatmap + ), + "Histogram" -> Seq( + histogram.BasicHistogram, + histogram.StyledBasicHistogram ) ) def unindent(source: String): String = { - val lines = source.linesIterator.toVector - val nonEmptyLines = lines.filter(_.exists(!_.isSpaceChar)) + val lines = source.linesIterator.toVector + val nonEmptyLines: Vector[String] = lines.filter(_.exists(!_.isSpaceChar)) if (nonEmptyLines.isEmpty) source else { - val dropCount = Stream + val dropCount = LazyList .from(0) - .takeWhile(idx => nonEmptyLines.forall(_(idx) == nonEmptyLines.head(idx))) + .takeWhile(idx => nonEmptyLines.forall(str => str(idx) == nonEmptyLines.head(idx))) .lastOption .fold(0)(_ + 1) @@ -102,7 +106,7 @@ import scalatags.JsDom.all.{area => _, _} mainDiv.appendChild(chartTypeElem.render) for (demo <- chartDemos) { - Console.println(s"Rendering demo ${demo.id}") + Console.println(s" Rendering demo ${demo.id}") val divId = s"demo-${demo.id}" diff --git a/demo/src/main/scala/plotly/demo/histogram/BasicHistogram.scala b/demo/src/main/scala/plotly/demo/histogram/BasicHistogram.scala new file mode 100644 index 0000000..b6e9ba4 --- /dev/null +++ b/demo/src/main/scala/plotly/demo/histogram/BasicHistogram.scala @@ -0,0 +1,31 @@ +package plotly.demo.histogram + +import plotly.Histogram +import plotly.demo.DemoChart +import plotly.layout.Layout + +object BasicHistogram extends DemoChart { + + def plotlyDocUrl = "https://plotly.com/javascript/histograms/#basic-histogram" + def id = this.getClass.getSimpleName.dropRight(1) + def source = BasicHistogramSource.source + + // demo source start + + private val categoryCount = 50 + + private val indices = LazyList.from(0).take(categoryCount) + private val categories = indices.map(i => s"name-$i") + private val values = indices.map(_ => math.random()) + + val data = Seq(Histogram(values, categories)) + + val layout = new Layout() + .withTitle(id) + .withShowlegend(false) + .withHeight(400) + .withWidth(600) + + // demo source end + +} diff --git a/demo/src/main/scala/plotly/demo/histogram/StyledBasicHistogram.scala b/demo/src/main/scala/plotly/demo/histogram/StyledBasicHistogram.scala new file mode 100644 index 0000000..7dbd86f --- /dev/null +++ b/demo/src/main/scala/plotly/demo/histogram/StyledBasicHistogram.scala @@ -0,0 +1,46 @@ +package plotly.demo.histogram + +import plotly.Histogram +import plotly.demo.DemoChart +import plotly.layout.{Axis, Layout, RangeSlider} +import plotly.element._ + +object StyledBasicHistogram extends DemoChart { + + def plotlyDocUrl = "https://plotly.com/javascript/histograms/#basic-histogram" + def id = this.getClass.getSimpleName.dropRight(1) + def source = StyledBasicHistogramSource.source + + // demo source start + + private val categoryCount = 50 + + private val indices = LazyList.from(0).take(categoryCount) + private val categories = indices.map(i => s"name-$i for $id") + private val values = indices.map(_ => math.random()) + + val data = Seq( + Histogram(values, categories) + .withMarker(new Marker().withColor(Color.StringColor("#004A72"))) + .withHovertext(categories.map(c => s"$c with hover text")) + ) + + val xAxis = new Axis() + .withRange((0d, 2d)) + .withRangeslider(RangeSlider()) + + val yAxis = new Axis() + .withTitle("Count") + .withFixedrange(true) + .withTickformat(".1f") + + val layout = new Layout() + .withXaxis(xAxis) + .withYaxis(yAxis) + .withTitle(id) + .withShowlegend(false) + .withHeight(400) + .withWidth(600) + + // demo source end +} diff --git a/project/Deps.scala b/project/Deps.scala index c793c9f..704a7ae 100644 --- a/project/Deps.scala +++ b/project/Deps.scala @@ -1,4 +1,3 @@ - import sbt._ import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._ @@ -7,15 +6,13 @@ object Deps { import Def.setting - def almondScalaApi = "sh.almond" %% "jupyter-api" % "0.13.14" + def almondScalaApi = "sh.almond" %% "jupyter-api" % "0.13.14" def argonautShapeless = setting("com.github.alexarchambault" %%% "argonaut-shapeless_6.3" % "1.3.1") - def dataClass = "io.github.alexarchambault" %% "data-class" % "0.2.6" - def jodaTime = "joda-time" % "joda-time" % "2.12.7" - def rhino = "org.mozilla" % "rhino" % "1.7.14" - def shapeless = setting("com.chuusai" %%% "shapeless" % "2.3.7") - def scalacheckShapeless = setting("com.github.alexarchambault" %%% "scalacheck-shapeless_1.15" % "1.3.0") - def scalajsDom = setting("org.scala-js" %%% "scalajs-dom" % "2.8.0") - def scalatags = setting("com.lihaoyi" %%% "scalatags" % "0.13.1") - def scalaTest = "org.scalatest" %% "scalatest" % "3.2.18" + def dataClass = "io.github.alexarchambault" %% "data-class" % "0.2.6" + def jodaTime = "joda-time" % "joda-time" % "2.12.7" + def rhino = "org.mozilla" % "rhino" % "1.7.15" + def scalajsDom = setting("org.scala-js" %%% "scalajs-dom" % "2.8.0") + def scalatags = setting("com.lihaoyi" %%% "scalatags" % "0.13.1") + def scalaTest = "org.scalatest" %% "scalatest" % "3.2.18" } diff --git a/render/js/src/main/scala/plotly/Plotly.scala b/render/js/src/main/scala/plotly/Plotly.scala index 7e2a91e..fa246d5 100644 --- a/render/js/src/main/scala/plotly/Plotly.scala +++ b/render/js/src/main/scala/plotly/Plotly.scala @@ -1,14 +1,13 @@ package plotly -import java.lang.{Boolean => JBoolean, Double => JDouble, Integer => JInt} - import argonaut.Argonaut._ -import argonaut.{Json, PrettyParams} +import argonaut.{EncodeJson, PrettyParams} import plotly.Codecs._ import plotly.element.Color import plotly.internals.BetterPrinter import plotly.layout._ +import java.lang.{Boolean => JBoolean, Double => JDouble, Integer => JInt} import scala.scalajs.js import scala.scalajs.js.Dynamic.{global => g} import scala.scalajs.js.JSON @@ -16,38 +15,58 @@ import scala.scalajs.js.JSON object Plotly { private val printer = BetterPrinter(PrettyParams.nospace.copy(dropNullKeys = true)) - private def stripNulls(json: Json): js.Any = { - // Remove empty objects - JSON.parse(printer.render(json)) + + // Remove empty objects + private def stripNulls[J: EncodeJson](value: J): js.Any = JSON.parse(printer.render(value.asJson)) + + trait PlotlyDyn { + def plotFn: js.Dynamic + + def apply(div: String, data: Seq[Trace], layout: Layout, config: Config): Unit = + plotFn( + div, + stripNulls(data), + stripNulls(layout), + stripNulls(config) + ) + + def apply(div: String, data: Seq[Trace], layout: Layout): Unit = + plotFn( + div, + stripNulls(data), + stripNulls(layout) + ) + + def apply(div: String, data: Seq[Trace]): Unit = + plotFn(div, stripNulls(data)) + + def apply(div: String, data: Trace, layout: Layout): Unit = + plotFn(div, stripNulls(data), stripNulls(layout)) + + def apply(div: String, data: Trace): Unit = + plotFn(div, stripNulls(data)) } - def plot(div: String, data: Seq[Trace], layout: Layout): Unit = { - g.Plotly.plot( - div, - stripNulls(data.asJson), - stripNulls(layout.asJson) - ) + object newPlot extends PlotlyDyn { + val plotFn: js.Dynamic = g.Plotly.newPlot } - def plot(div: String, data: Seq[Trace]): Unit = { - g.Plotly.plot( - div, - stripNulls(data.asJson) - ) + object plot extends PlotlyDyn { + val plotFn: js.Dynamic = g.Plotly.newPlot } - def plot(div: String, data: Trace, layout: Layout): Unit = - g.Plotly.plot( - div, - stripNulls(data.asJson), - stripNulls(layout.asJson) - ) - - def plot(div: String, data: Trace): Unit = - g.Plotly.plot( - div, - stripNulls(data.asJson) - ) + object react extends PlotlyDyn { + val plotFn: js.Dynamic = g.Plotly.react + } + + def relayout(div: String, layout: Layout): Unit = + g.Plotly.relayout(div, stripNulls(layout)) + + def purge(div: String): Unit = + g.Plotly.purge(div) + + def validate(data: Seq[Trace], layout: Layout, config: Config): Unit = + g.Plotly.validate(stripNulls(data), stripNulls(layout)) implicit class TraceOps(val trace: Trace) extends AnyVal { def plot(div: String, layout: Layout): Unit =