Skip to content

Commit 2dcc179

Browse files
committed
inline maybe
1 parent 98b465e commit 2dcc179

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

src/marks/auto.js

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -115,28 +115,28 @@ export function autoSpec(data, options) {
115115
case "bar":
116116
markImpl =
117117
colorReduce != null || sizeReduce != null // bin or group on both x and y
118-
? maybeIsOrdinal(X) && maybeIsOrdinal(Y)
118+
? X && isOrdinal(X) && Y && isOrdinal(Y)
119119
? cell
120-
: maybeIsOrdinal(X)
120+
: X && isOrdinal(X)
121121
? barY
122-
: maybeIsOrdinal(Y)
122+
: Y && isOrdinal(Y)
123123
? barX
124124
: rect
125125
: xReduce != null // bin or group on y
126126
? isOrdinal(Y)
127-
? isSelectReducer(xReduce) && maybeIsOrdinal(X)
127+
? isSelectReducer(xReduce) && X && isOrdinal(X)
128128
? cell
129129
: barX
130130
: rectX
131131
: yReduce != null // bin or group on x
132132
? isOrdinal(X)
133-
? isSelectReducer(yReduce) && maybeIsOrdinal(Y)
133+
? isSelectReducer(yReduce) && Y && isOrdinal(Y)
134134
? cell
135135
: barY
136136
: rectY
137-
: maybeIsNumeric(X) && !maybeIsNumeric(Y)
137+
: X && isNumeric(X) && !(Y && isNumeric(Y))
138138
? barX // if y is temporal, treat as ordinal
139-
: maybeIsNumeric(Y) && !maybeIsNumeric(X)
139+
: Y && isNumeric(Y) && !(X && isNumeric(X))
140140
? barY // if x is temporal, treat as ordinal
141141
: cell;
142142
colorMode = "fill";
@@ -305,16 +305,6 @@ function isSelectReducer(reduce) {
305305
return /^(?:first|last|mode)$/i.test(reduce);
306306
}
307307

308-
// We can’t infer the type of a custom reducer without invoking it, so
309-
// assume most reducers produce quantitative values.
310-
function maybeIsOrdinal(values) {
311-
return values != null && isOrdinal(values);
312-
}
313-
314-
function maybeIsNumeric(values) {
315-
return values != null && isNumeric(values);
316-
}
317-
318308
// https://github.com/observablehq/plot/blob/818562649280e155136f730fc496e0b3d15ae464/src/transforms/group.js#L236
319309
function isReducer(reduce) {
320310
if (reduce == null) return false;

0 commit comments

Comments
 (0)