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

Allow fallback color specification for incomplete domain-range mapping #6708

Closed
stefanv opened this issue Jun 29, 2020 · 3 comments · Fixed by #8451
Closed

Allow fallback color specification for incomplete domain-range mapping #6708

stefanv opened this issue Jun 29, 2020 · 3 comments · Fixed by #8451
Labels
Milestone

Comments

@stefanv
Copy link

stefanv commented Jun 29, 2020

I have a scatter plot where the color of each point is determined by a certain field. I don't know all the values that the field can take, but I know that if that field has value "red", "green", or "blue", I want the points to appear in the corresponding color.

Currently, as per this StackOverflow answer, there is no way to provide discrete colors with a fallback.

@domoritz domoritz added the P4 Nice to Have label Jun 29, 2020
@kanitw
Copy link
Member

kanitw commented Jun 29, 2020

We should make the following work:

{
  "$schema": "https://vega.github.io/schema/vega-lite/v4.json",
  "description": "A simple bar chart with embedded data.",
  "data": {
    "values": [
      {"a": "A", "b": 28}, 
      {"a": "B", "b": 55}, 
      {"a": "C", "b": 43},
      {"a": "D", "b": 91}
    ]
  },
  "mark": "bar",
  "encoding": {
    "x": {"field": "a", "type": "ordinal", "axis": {"labelAngle": 0}},
    "y": {"field": "b", "type": "quantitative"},
    "color": {"field": "a", "type": "nominal", "scale": {
      "domain": {"unionWith": ["A", "C"]},
      "range": ["red", "green", "blue", "teal"]
    }, "sort": null}
  }
}

image

The tricky part is that:

{
  "name": "color",
  "type": "ordinal",
  "domain": {"fields": [{"data": "data_0", "field": "a"}, ["A", "B"]]},
  "range": ["red", "green", "blue", "teal"]
}

Besides, the other missing part is that you can't define custom mapping for a few colors and fill the rest with a predefined scheme

@stefanv
Copy link
Author

stefanv commented Dec 3, 2020

@kanitw I was wondering if you had suggestions for a workaround to this issue? Sorry to bug.

@scizen9
Copy link

scizen9 commented Apr 1, 2021

@kanitw is there any way to bump this up in priority? We are stuck until we can solve this or at least work around it. If there is anything we can do to help, please let us know. Thanks!

@kanitw kanitw added this to the 2022 Aug Polishes milestone Oct 5, 2022
kanitw pushed a commit that referenced this issue Oct 10, 2022
Co-authored-by: GitHub Actions Bot <vega-actions-bot@users.noreply.github.com>
kanitw added a commit that referenced this issue Oct 10, 2022
kanitw added a commit that referenced this issue Oct 10, 2022
)

* Revert "fix(#6708): change domain order for union with (#8451)"

This reverts commit d4591fb.

* fix: Revert "Revert "fix(#6708): change domain order for union with (#8451)""

This reverts commit efc42b5.
BradyJ27 pushed a commit to BradyJ27/vega-lite that referenced this issue Oct 19, 2023
Co-authored-by: GitHub Actions Bot <vega-actions-bot@users.noreply.github.com>
BradyJ27 pushed a commit to BradyJ27/vega-lite that referenced this issue Oct 19, 2023
…vega#8468)

* Revert "fix(vega#6708): change domain order for union with (vega#8451)"

This reverts commit d4591fb.

* fix: Revert "Revert "fix(vega#6708): change domain order for union with (vega#8451)""

This reverts commit efc42b5.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants