Skip to content

Commit 04518d1

Browse files
Bump documentation, add missing definitions
1 parent 334122d commit 04518d1

File tree

9 files changed

+143
-76
lines changed

9 files changed

+143
-76
lines changed

core/shared/src/main/scala/plotly/Trace.scala

Lines changed: 85 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,29 @@ import plotly.element._
1010
sealed abstract class Trace extends Product with Serializable
1111

1212
@data(optionSetters = true) class Scatter(
13-
x: Option[Sequence] = None,
14-
y: Option[Sequence] = None,
15-
text: Option[OneOrSeq[String]] = None,
16-
mode: Option[ScatterMode] = None,
17-
marker: Option[Marker] = None,
18-
line: Option[Line] = None,
19-
textposition: Option[TextPosition] = None,
20-
textfont: Option[TextFont] = None,
21-
name: Option[String] = None,
22-
connectgaps: Option[Boolean] = None,
23-
xaxis: Option[AxisReference] = None,
24-
yaxis: Option[AxisReference] = None,
25-
fill: Option[Fill] = None,
26-
error_x: Option[Error] = None,
27-
error_y: Option[Error] = None,
28-
showlegend: Option[Boolean] = None,
29-
fillcolor: Option[OneOrSeq[Color]] = None,
30-
hoverinfo: Option[HoverInfo] = None,
31-
hoveron: Option[HoverOn] = None,
32-
stackgroup: Option[String] = None,
33-
groupnorm: Option[GroupNorm] = None
13+
x: Option[Sequence] = None,
14+
y: Option[Sequence] = None,
15+
text: Option[OneOrSeq[String]] = None,
16+
mode: Option[ScatterMode] = None,
17+
marker: Option[Marker] = None,
18+
line: Option[Line] = None,
19+
textposition: Option[TextPosition] = None,
20+
textfont: Option[TextFont] = None,
21+
name: Option[String] = None,
22+
connectgaps: Option[Boolean] = None,
23+
xaxis: Option[AxisReference] = None,
24+
yaxis: Option[AxisReference] = None,
25+
fill: Option[Fill] = None,
26+
error_x: Option[Error] = None,
27+
error_y: Option[Error] = None,
28+
showlegend: Option[Boolean] = None,
29+
fillcolor: Option[OneOrSeq[Color]] = None,
30+
hoverinfo: Option[HoverInfo] = None,
31+
hoveron: Option[HoverOn] = None,
32+
stackgroup: Option[String] = None,
33+
groupnorm: Option[GroupNorm] = None,
34+
@since("0.8.2")
35+
hovertemplate: Option[OneOrSeq[String]] = None
3436
) extends Trace
3537

3638
object Scatter {
@@ -97,19 +99,21 @@ object Scatter {
9799
}
98100

99101
@data(optionSetters = true) class Box(
100-
y: Option[Sequence] = None,
101-
x: Option[Sequence] = None,
102-
boxpoints: Option[BoxPoints] = None,
103-
jitter: Option[Double] = None,
104-
pointpos: Option[Double] = None,
105-
name: Option[String] = None,
106-
marker: Option[Marker] = None,
107-
orientation: Option[Orientation] = None,
108-
whiskerwidth: Option[Double] = None,
109-
boxmean: Option[BoxMean] = None,
110-
fillcolor: Option[OneOrSeq[Color]] = None,
111-
line: Option[Line] = None,
112-
showlegend: Option[Boolean] = None
102+
y: Option[Sequence] = None,
103+
x: Option[Sequence] = None,
104+
boxpoints: Option[BoxPoints] = None,
105+
jitter: Option[Double] = None,
106+
pointpos: Option[Double] = None,
107+
name: Option[String] = None,
108+
marker: Option[Marker] = None,
109+
orientation: Option[Orientation] = None,
110+
whiskerwidth: Option[Double] = None,
111+
boxmean: Option[BoxMean] = None,
112+
fillcolor: Option[OneOrSeq[Color]] = None,
113+
line: Option[Line] = None,
114+
showlegend: Option[Boolean] = None,
115+
@since("0.8.2")
116+
hovertemplate: Option[OneOrSeq[String]] = None
113117
) extends Trace
114118

115119
object Box {
@@ -153,22 +157,24 @@ object Box {
153157
}
154158

155159
@data(optionSetters = true) class Bar(
156-
x: Sequence,
157-
y: Sequence,
160+
x: Sequence,
161+
y: Sequence,
158162
@since
159-
name: Option[String] = None,
160-
text: Option[Seq[String]] = None,
161-
marker: Option[Marker] = None,
162-
orientation: Option[Orientation] = None,
163-
xaxis: Option[AxisReference] = None,
164-
yaxis: Option[AxisReference] = None,
165-
error_y: Option[Error] = None,
166-
showlegend: Option[Boolean] = None,
167-
hoverinfo: Option[HoverInfo] = None,
168-
textposition: Option[BarTextPosition] = None,
169-
opacity: Option[Double] = None,
170-
width: Option[OneOrSeq[Double]] = None,
171-
base: Option[OneOrSeq[Double]] = None
163+
name: Option[String] = None,
164+
text: Option[Seq[String]] = None,
165+
marker: Option[Marker] = None,
166+
orientation: Option[Orientation] = None,
167+
xaxis: Option[AxisReference] = None,
168+
yaxis: Option[AxisReference] = None,
169+
error_y: Option[Error] = None,
170+
showlegend: Option[Boolean] = None,
171+
hoverinfo: Option[HoverInfo] = None,
172+
textposition: Option[BarTextPosition] = None,
173+
opacity: Option[Double] = None,
174+
width: Option[OneOrSeq[Double]] = None,
175+
base: Option[OneOrSeq[Double]] = None,
176+
@since("0.8.2")
177+
hovertemplate: Option[OneOrSeq[String]] = None
172178
) extends Trace
173179

174180
object Bar {
@@ -210,17 +216,19 @@ object Bar {
210216
}
211217

212218
@data(optionSetters = true) class Histogram(
213-
x: Option[Sequence] = None,
214-
y: Option[Sequence] = None,
215-
opacity: Option[Double] = None,
216-
name: Option[String] = None,
217-
autobinx: Option[Boolean] = None,
218-
marker: Option[Marker] = None,
219-
xbins: Option[Bins] = None,
220-
histnorm: Option[HistNorm] = None,
221-
showlegend: Option[Boolean] = None,
222-
cumulative: Option[Cumulative] = None,
223-
histfunc: Option[HistFunc] = None
219+
x: Option[Sequence] = None,
220+
y: Option[Sequence] = None,
221+
opacity: Option[Double] = None,
222+
name: Option[String] = None,
223+
autobinx: Option[Boolean] = None,
224+
marker: Option[Marker] = None,
225+
xbins: Option[Bins] = None,
226+
histnorm: Option[HistNorm] = None,
227+
showlegend: Option[Boolean] = None,
228+
cumulative: Option[Cumulative] = None,
229+
histfunc: Option[HistFunc] = None,
230+
@since("0.8.2")
231+
hovertemplate: Option[OneOrSeq[String]] = None
224232
) extends Trace
225233

226234
object Histogram {
@@ -260,11 +268,13 @@ object Histogram {
260268
}
261269

262270
@data(optionSetters = true) class Surface(
263-
x: Option[Sequence] = None,
264-
y: Option[Sequence] = None,
265-
z: Option[Sequence] = None,
266-
showscale: Option[Boolean] = None,
267-
opacity: Option[Double] = None
271+
x: Option[Sequence] = None,
272+
y: Option[Sequence] = None,
273+
z: Option[Sequence] = None,
274+
showscale: Option[Boolean] = None,
275+
opacity: Option[Double] = None,
276+
@since("0.8.2")
277+
hovertemplate: Option[OneOrSeq[String]] = None
268278
) extends Trace
269279

270280
object Surface {
@@ -286,13 +296,16 @@ object Surface {
286296
}
287297

288298
@data(optionSetters = true) class Heatmap(
289-
y: Option[Sequence] = None,
290-
x: Option[Sequence] = None,
291-
z: Option[Sequence] = None,
292-
autocolorscale: Option[Boolean] = None,
293-
colorscale: Option[ColorScale] = None,
294-
showscale: Option[Boolean] = None,
295-
name: Option[String] = None
299+
y: Option[Sequence] = None,
300+
x: Option[Sequence] = None,
301+
z: Option[Sequence] = None,
302+
autocolorscale: Option[Boolean] = None,
303+
colorscale: Option[ColorScale] = None,
304+
showscale: Option[Boolean] = None,
305+
name: Option[String] = None,
306+
@since("0.8.2")
307+
hovertemplate: Option[OneOrSeq[String]] = None,
308+
hoverongaps: Option[Boolean] = None
296309
) extends Trace
297310

298311
object Heatmap {

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ import plotly.element._
4343
nticks: Option[Int] = None,
4444
automargin: Option[Boolean] = None,
4545
@since("0.8.0")
46-
rangeslider: Option[RangeSlider] = None
46+
rangeslider: Option[RangeSlider] = None,
47+
@since("0.8.2")
48+
width: Option[Int] = None,
49+
height: Option[Int] = None,
50+
autosize: Option[Boolean] = None
4751
)
4852

4953
object Axis {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package plotly.layout
2+
3+
import dataclass.data
4+
5+
@data(optionSetters = true) class Grid(
6+
rows: Option[Int] = None,
7+
columns: Option[Int] = None,
8+
pattern: Option[Pattern] = None,
9+
roworder: Option[RowOrder] = None,
10+
subplots: Option[Seq[Seq[String]]] = None
11+
)

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ import plotly.element._
3636
scene: Option[Scene] = None,
3737
@since("0.8.0")
3838
dragmode: Option[String] = None,
39-
shapes: Option[Seq[Shape]] = None
39+
shapes: Option[Seq[Shape]] = None,
40+
@since("0.8.2")
41+
grid: Option[Grid] = None
4042
)
4143

4244
object Layout {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package plotly.layout
2+
3+
sealed abstract class Pattern(val label: String) extends Product with Serializable
4+
5+
object Pattern {
6+
case object Independent extends Pattern("independent")
7+
case object Coupled extends Pattern("coupled")
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package plotly.layout
2+
3+
sealed abstract class RowOrder(val label: String) extends Product with Serializable
4+
5+
object RowOrder {
6+
case object TopToBottom extends RowOrder("top to bottom")
7+
case object BottomToTop extends RowOrder("bottom to top")
8+
}

plotly-documentation

render/shared/src/main/scala/plotly/internals/ArgonautCodecsInternals.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ object ArgonautCodecsInternals extends ArgonautCodecsExtra {
146146
implicit val hoverOnIsEnum = IsEnum.instance[HoverOn](_.label)
147147
implicit val groupNormIsEnum = IsEnum.instance[GroupNorm](_.label)
148148
implicit val histFuncIsEnum = IsEnum.instance[HistFunc](_.label)
149+
implicit val tickModeIsEnum = IsEnum.instance[TickMode](_.mode)
150+
implicit val patternIsEnum = IsEnum.instance[Pattern](_.label)
151+
implicit val rowOrderIsEnum = IsEnum.instance[RowOrder](_.label)
149152

150153
def jsonSumDirectCodecFor(name: String): JsonSumCodec = new JsonSumCodec {
151154
def encodeEmpty: Nothing =

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ object DocumentationTests {
6868
var dataOpt = Option.empty[Object]
6969
var layoutOpt = Option.empty[Object]
7070

71+
def newPlot(div: String, data: Object, layout: Object, other: Object): Unit = {
72+
dataOpt = Option(data)
73+
layoutOpt = Option(layout)
74+
}
75+
7176
def newPlot(div: String, data: Object, layout: Object): Unit = {
7277
dataOpt = Option(data)
7378
layoutOpt = Option(layout)
@@ -116,12 +121,20 @@ object DocumentationTests {
116121
val step = (to - from).toDouble / (count - 1)
117122
new NativeArrayWithDefault((0 until count).map(n => from + n * step: JDouble).toArray[AnyRef], 0.0: JDouble)
118123
}
124+
def linspace(from: Double, to: Double, count: Int) = {
125+
val step = (to - from) / (count - 1)
126+
new NativeArrayWithDefault((0 until count).map(n => from + n * step: JDouble).toArray[AnyRef], 0.0: JDouble)
127+
}
119128
}
120129

121130
def linspaceImpl(cx: Context, thisObj: Scriptable, args: Array[Object], funObj: Function): AnyRef =
122131
args.toSeq.map(x => x: Any) match {
123132
case Seq(from: Int, to: Int, step: Int) =>
124133
Numeric.linspace(from, to, step)
134+
case Seq(from: Double, to: Int, step: Int) =>
135+
Numeric.linspace(from, to.toDouble, step)
136+
case Seq(from: Double, to: Double, step: Int) =>
137+
Numeric.linspace(from, to, step)
125138
case other => throw new NoSuchElementException(s"linspace${other.mkString("(", ", ", ")")}")
126139
}
127140

@@ -155,6 +168,7 @@ object DocumentationTests {
155168
ScriptableObject.putProperty(scope, "document", Document)
156169
ScriptableObject.putProperty(scope, "numeric", Numeric)
157170
ScriptableObject.putProperty(scope, "require", require(scope))
171+
ScriptableObject.putProperty(scope, "linspace", linspace(scope))
158172
cx.evaluateString(scope, demo, "<cmd>", 1, null)
159173
plotly.result(cx, scope)
160174
} catch {
@@ -233,7 +247,7 @@ class DocumentationTests extends AnyFlatSpec with Matchers {
233247
// "financial/ohlc",
234248
"basic/bubble",
235249
"basic/area",
236-
"layout/sizing",
250+
"fundamentals/sizing",
237251
// TODO? Gauge charts
238252
// TODO Multiple chart types (needs contour)
239253
// TODO Shapes (need mock of d3)
@@ -273,6 +287,10 @@ class DocumentationTests extends AnyFlatSpec with Matchers {
273287
.replace("</br>", "\\n")
274288
.replace("(...size)", "(size[0])") // rhino doesn't seem to support the spead (...) operator
275289
.replace("desired_maximum_marker_size**2", "desired_maximum_marker_size*desired_maximum_marker_size")
290+
.replace("""function linspace(a,b,n) {
291+
return Plotly.d3.range(n).map(function(i){return a+i*(b-a)/(n-1);});
292+
}
293+
""", "")
276294

277295
if (content.contains("Plotly.d3.csv"))
278296
println(s"Ignoring $post (Plotly.d3.csv not implemented)")

0 commit comments

Comments
 (0)