|
1 | 1 | import {ascending, InternSet} from "d3"; |
2 | | -import {isOrdinal, labelof, valueof, isOptions, isColor} from "../options.js"; |
3 | | -import {area, areaX, areaY} from "./area.js"; |
| 2 | +import {isOrdinal, labelof, valueof, isOptions, isColor, isObject} from "../options.js"; |
| 3 | +import {areaX, areaY} from "./area.js"; |
4 | 4 | import {dot} from "./dot.js"; |
5 | 5 | import {line, lineX, lineY} from "./line.js"; |
6 | 6 | import {ruleX, ruleY} from "./rule.js"; |
@@ -123,16 +123,7 @@ export function auto(data, {x, y, color, size, fx, fy, mark} = {}) { |
123 | 123 | if (isHighCardinality(color)) z = null; // TODO only if z not set by user |
124 | 124 | break; |
125 | 125 | case "area": |
126 | | - mark = |
127 | | - x && y |
128 | | - ? isContinuous(x) && isMonotonic(x) |
129 | | - ? areaY |
130 | | - : isContinuous(y) && isMonotonic(y) |
131 | | - ? areaX |
132 | | - : area // TODO error? how does it work with ordinal? |
133 | | - : x |
134 | | - ? areaX |
135 | | - : areaY; // 1d area by index |
| 126 | + mark = yZero ? areaY : xZero || (y && isMonotonic(y)) ? areaX : areaY; // favor areaY if unsure |
136 | 127 | colorMode = "fill"; |
137 | 128 | if (isHighCardinality(color)) z = null; // TODO only if z not set by user |
138 | 129 | break; |
@@ -240,7 +231,7 @@ function isZeroReducer(reduce) { |
240 | 231 |
|
241 | 232 | // https://github.com/observablehq/plot/blob/818562649280e155136f730fc496e0b3d15ae464/src/transforms/group.js#L236 |
242 | 233 | function isReducer(reduce) { |
243 | | - if (typeof reduce?.reduce === "function") return true; |
| 234 | + if (typeof reduce?.reduce === "function" && isObject(reduce)) return true; // N.B. array.reduce |
244 | 235 | if (/^p\d{2}$/i.test(reduce)) return true; |
245 | 236 | switch (`${reduce}`.toLowerCase()) { |
246 | 237 | case "first": |
|
0 commit comments