Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine “high cardinality” warning #1668

Merged
merged 1 commit into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ function groupAesthetics(

export function groupZ(I, Z, z) {
const G = group(I, (i) => Z[i]);
if (z === undefined && G.size > I.length >> 1) {
if (z === undefined && G.size > (1 + I.length) >> 1) {
warn(
`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.`
);
Expand Down
26 changes: 26 additions & 0 deletions test/output/pairsArea.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions test/plots/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export * from "./music-revenue.js";
export * from "./npm-versions.js";
export * from "./opacity.js";
export * from "./ordinal-bar.js";
export * from "./pairs.js";
export * from "./penguin-annotated.js";
export * from "./penguin-culmen-array.js";
export * from "./penguin-culmen-delaunay-mesh.js";
Expand Down
6 changes: 6 additions & 0 deletions test/plots/pairs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import * as Plot from "@observablehq/plot";
import * as d3 from "d3";

export async function pairsArea() {
return Plot.areaY({length: 15}, {y: d3.randomLcg(42), stroke: (d, i) => i >> 1}).plot({axis: null, height: 140});
}