Skip to content

Commit 4fc7d16

Browse files
committed
Add a few axis options. Fixes #41, fixes #42
1 parent 0328584 commit 4fc7d16

File tree

4 files changed

+37
-6
lines changed

4 files changed

+37
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package plotly.element
2+
3+
sealed abstract class TickMode(val mode: String) extends Product with Serializable
4+
5+
object TickMode {
6+
case object Auto extends TickMode("auto")
7+
case object Linear extends TickMode("linear")
8+
case object Array extends TickMode("array")
9+
}
10+
11+

core/shared/src/main/scala/plotly/layout/Axis.scala

+19-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@ final case class Axis(
3333
anchor: Option[AxisAnchor],
3434
`type`: Option[AxisType],
3535
overlaying: Option[AxisAnchor],
36-
position: Option[Double]
36+
position: Option[Double],
37+
tickmode: Option[TickMode],
38+
tickvals: Option[Sequence],
39+
ticktext: Option[Sequence],
40+
nticks: Option[Int],
41+
automargin: Option[Boolean]
3742
)
3843

3944
object Axis {
@@ -65,7 +70,13 @@ object Axis {
6570
anchor: AxisAnchor = null,
6671
`type`: AxisType = null,
6772
overlaying: AxisAnchor = null,
68-
position: JDouble = null
73+
position: JDouble = null,
74+
tickmode: TickMode = null,
75+
tickvals: Sequence = null,
76+
ticktext: Sequence = null,
77+
nticks: JInt = null,
78+
automargin: JBoolean = null,
79+
6980
): Axis =
7081
Axis(
7182
Option(title),
@@ -95,6 +106,11 @@ object Axis {
95106
Option(anchor),
96107
Option(`type`),
97108
Option(overlaying),
98-
Option(position) .map(x => x: Double)
109+
Option(position) .map(x => x: Double),
110+
Option(tickmode),
111+
Option(tickvals),
112+
Option(ticktext),
113+
Option(nticks) .map(x => x: Int),
114+
Option(automargin) .map(x => x: Boolean)
99115
)
100116
}

core/shared/src/main/scala/plotly/layout/Margin.scala

+6-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ final case class Margin(
88
l: Option[Int],
99
r: Option[Int],
1010
t: Option[Int],
11-
b: Option[Int]
11+
b: Option[Int],
12+
pad: Option[Int],
1213
)
1314

1415
object Margin {
@@ -17,13 +18,15 @@ object Margin {
1718
l: JInt = null,
1819
r: JInt = null,
1920
t: JInt = null,
20-
b: JInt = null
21+
b: JInt = null,
22+
pad: JInt = null
2123
): Margin =
2224
Margin(
2325
Option(autoexpand).map(b => b: Boolean),
2426
Option(l).map(n => n: Int),
2527
Option(r).map(n => n: Int),
2628
Option(t).map(n => n: Int),
27-
Option(b).map(n => n: Int)
29+
Option(b).map(n => n: Int),
30+
Option(pad).map(n => n: Int)
2831
)
2932
}

tests/src/test/scala/plotly/doc/DocumentationTests.scala

+1
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ class DocumentationTests extends FlatSpec with Matchers {
233233
"financial/time-series",
234234
"basic/bubble",
235235
"basic/area",
236+
"layout/sizing",
236237
// TODO? Gauge charts
237238
// TODO Multiple chart types (needs contour)
238239
// TODO Shapes (need mock of d3)

0 commit comments

Comments
 (0)