Skip to content

Commit

Permalink
Merge pull request #43 from sbrunk/automargin
Browse files Browse the repository at this point in the history
Add a few axis options
  • Loading branch information
sbrunk authored Nov 28, 2018
2 parents bae2349 + f8b9567 commit 922a12d
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 8 deletions.
4 changes: 2 additions & 2 deletions almond/src/main/scala/plotly/Almond.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ object Almond {
|});
""".stripMargin
else
"""require.config({
s"""require.config({
| paths: {
| d3: 'https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.17/d3.min',
| plotly: 'https://cdn.plot.ly/plotly-1.12.0.min',
| plotly: 'https://cdn.plot.ly/plotly-${Plotly.plotlyVersion}.min',
| jquery: 'https://code.jquery.com/jquery-3.3.1.min'
| },
|
Expand Down
11 changes: 11 additions & 0 deletions core/shared/src/main/scala/plotly/element/TickMode.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package plotly.element

sealed abstract class TickMode(val mode: String) extends Product with Serializable

object TickMode {
case object Auto extends TickMode("auto")
case object Linear extends TickMode("linear")
case object Array extends TickMode("array")
}


21 changes: 18 additions & 3 deletions core/shared/src/main/scala/plotly/layout/Axis.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ final case class Axis(
anchor: Option[AxisAnchor],
`type`: Option[AxisType],
overlaying: Option[AxisAnchor],
position: Option[Double]
position: Option[Double],
tickmode: Option[TickMode],
tickvals: Option[Sequence],
ticktext: Option[Sequence],
nticks: Option[Int],
automargin: Option[Boolean]
)

object Axis {
Expand Down Expand Up @@ -65,7 +70,12 @@ object Axis {
anchor: AxisAnchor = null,
`type`: AxisType = null,
overlaying: AxisAnchor = null,
position: JDouble = null
position: JDouble = null,
tickmode: TickMode = null,
tickvals: Sequence = null,
ticktext: Sequence = null,
nticks: JInt = null,
automargin: JBoolean = null
): Axis =
Axis(
Option(title),
Expand Down Expand Up @@ -95,6 +105,11 @@ object Axis {
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)
)
}
9 changes: 6 additions & 3 deletions core/shared/src/main/scala/plotly/layout/Margin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ final case class Margin(
l: Option[Int],
r: Option[Int],
t: Option[Int],
b: Option[Int]
b: Option[Int],
pad: Option[Int]
)

object Margin {
Expand All @@ -17,13 +18,15 @@ object Margin {
l: JInt = null,
r: JInt = null,
t: JInt = null,
b: JInt = null
b: JInt = null,
pad: JInt = null
): Margin =
Margin(
Option(autoexpand).map(b => b: Boolean),
Option(l).map(n => n: Int),
Option(r).map(n => n: Int),
Option(t).map(n => n: Int),
Option(b).map(n => n: Int)
Option(b).map(n => n: Int),
Option(pad).map(n => n: Int)
)
}
1 change: 1 addition & 0 deletions tests/src/test/scala/plotly/doc/DocumentationTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ class DocumentationTests extends FlatSpec with Matchers {
"financial/time-series",
"basic/bubble",
"basic/area",
"layout/sizing",
// TODO? Gauge charts
// TODO Multiple chart types (needs contour)
// TODO Shapes (need mock of d3)
Expand Down

0 comments on commit 922a12d

Please sign in to comment.