Skip to content

Can't set unknown domain in colour scale #446

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

Closed
rossburton opened this issue Jun 30, 2021 · 4 comments · Fixed by #559
Closed

Can't set unknown domain in colour scale #446

rossburton opened this issue Jun 30, 2021 · 4 comments · Fixed by #559
Labels
enhancement New feature or request

Comments

@rossburton
Copy link

I'm using the color scale with explicit domain/range to associate status names with colours:

  color: {
    type: "categorical",
    domain: ["success", "failed"],
    range: ["green", "red"]
  },

But status names I forgot to list come out invisible. A way of setting the unknown() value would be useful, it looks like it is hardcoded to undefined at

return ScaleO(scaleOrdinal().unknown(undefined), channels, {range, ...options});
.

@Fil Fil added the enhancement New feature or request label Jun 30, 2021
@mbostock
Copy link
Member

Anything outside the domain will not be plotted; we need the “other” transform for this use case.

@zanarmstrong
Copy link

I ran into something that seems similar related to NAs when plotting height / weight the Olympics dataset. Example here.

@Fil
Copy link
Contributor

Fil commented Sep 14, 2021

Another use-case (very similar to Zan's) can be found in https://observablehq.com/@rcatlord/spine-charts; for some of the areas (try "Rother" in the select), the value comes in as "NA" instead of a number, and the x axis switches to a categorical scale.

Capture d’écran 2021-09-14 à 09 03 15

@Fil
Copy link
Contributor

Fil commented Sep 27, 2021

With this feature:

  • In Zan's example the N/A can be shown by applying
  x: { unknown: 45 },
  y: { unknown: 10 }
  • In rcatlord's example, the fix is a bit more complicated, since we need to coerce the scale to be quantitative:
x: {
  axis: "top",
  label: null,
  type: "linear",
  unknown: 650
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants