File tree 2 files changed +25
-1
lines changed
main/scala/co/theasi/plotly/writer
test/scala/co/theasi/plotly/writer 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ package co.theasi.plotly.writer
3
3
import org .json4s ._
4
4
import org .json4s .JsonDSL ._
5
5
6
- import co .theasi .plotly .AxisOptions
6
+ import co .theasi .plotly .{ AxisOptions , AxisType }
7
7
8
8
object AxisOptionsWriter {
9
9
def toJson (options : AxisOptions ): JObject = (
@@ -18,7 +18,16 @@ object AxisOptionsWriter {
18
18
(" tickfont" -> FontWriter .toJson(options.tickFont)) ~
19
19
(" autotick" -> options.autoTick) ~
20
20
(" dtick" -> options.tickSpacing) ~
21
+ (" type" -> axisTypeToJson(options.axisType)) ~
22
+
21
23
(" tickcolor" -> options.tickColor.map(ColorWriter .toJson _)) ~
22
24
(" showticklabels" -> options.tickLabels)
23
25
)
26
+
27
+ private def axisTypeToJson (axisTypeMaybe : Option [AxisType .Value ]): JValue = {
28
+ axisTypeMaybe match {
29
+ case Some (axisType) => JString (axisType.toString)
30
+ case None => JNothing
31
+ }
32
+ }
24
33
}
Original file line number Diff line number Diff line change
1
+ package co .theasi .plotly .writer
2
+
3
+ import org .scalatest .{FlatSpec , Matchers }
4
+
5
+ import org .json4s .JString
6
+
7
+ import co .theasi .plotly .{AxisOptions , AxisType }
8
+
9
+ class AxisOptionsWriterSpec extends FlatSpec with Matchers {
10
+ " toJson" should " serialize the plot type" in {
11
+ val options = AxisOptions ().axisType(AxisType .Log )
12
+ val jobj = AxisOptionsWriter .toJson(options)
13
+ jobj \ " type" shouldEqual JString (" log" )
14
+ }
15
+ }
You can’t perform that action at this time.
0 commit comments