Skip to content

Commit 051e0d2

Browse files
committed
Refine “high cardinality” warning (#1668)
1 parent 1cd291f commit 051e0d2

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

src/style.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ function groupAesthetics(
252252

253253
export function groupZ(I, Z, z) {
254254
const G = group(I, (i) => Z[i]);
255-
if (z === undefined && G.size > I.length >> 1) {
255+
if (z === undefined && G.size > (1 + I.length) >> 1) {
256256
warn(
257257
`Warning: the implicit z channel has high cardinality. This may occur when the fill or stroke channel is associated with quantitative data rather than ordinal or categorical data. You can suppress this warning by setting the z option explicitly; if this data represents a single series, set z to null.`
258258
);

test/output/pairsArea.svg

+26
Loading

test/plots/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ export * from "./music-revenue.js";
168168
export * from "./npm-versions.js";
169169
export * from "./opacity.js";
170170
export * from "./ordinal-bar.js";
171+
export * from "./pairs.js";
171172
export * from "./penguin-annotated.js";
172173
export * from "./penguin-culmen-array.js";
173174
export * from "./penguin-culmen-delaunay-mesh.js";

test/plots/pairs.ts

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import * as Plot from "@observablehq/plot";
2+
import * as d3 from "d3";
3+
4+
export async function pairsArea() {
5+
return Plot.areaY({length: 15}, {y: d3.randomLcg(42), stroke: (d, i) => i >> 1}).plot({axis: null, height: 140});
6+
}

0 commit comments

Comments
 (0)