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

Categorical "count" field on color doesn't work for line and area #9281

Open
1 task done
yhoonkim opened this issue Mar 8, 2024 · 3 comments
Open
1 task done

Categorical "count" field on color doesn't work for line and area #9281

yhoonkim opened this issue Mar 8, 2024 · 3 comments
Labels

Comments

@yhoonkim
Copy link
Contributor

yhoonkim commented Mar 8, 2024

Bug Description

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "data": {
    "values": [
      {"category":"A", "count": 1, "value":0.1},
      {"category":"A", "count": 2, "value":0.6},
      {"category":"A", "count": 3, "value":0.9},
      {"category":"B", "count": 1, "value":0.7},
      {"category":"B", "count": 2, "value":0.2},
      {"category":"B", "count": 3, "value":1.1},
      {"category":"C", "count": 1, "value":0.6},
      {"category":"C", "count": 2, "value":0.1},
      {"category":"C", "count": 3, "value":0.2}
    ]
  },
  "mark": "line",
  "encoding": {
    "x": {"field": "category"},
    "y": {"field": "value", "type": "quantitative"},
    "color": {"field": "count"}
  }
}

image

Note that if we change "count" -> "_count", it works well:

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "data": {
    "values": [
      {"category":"A", "_count": 1, "value":0.1},
      {"category":"A", "_count": 2, "value":0.6},
      {"category":"A", "_count": 3, "value":0.9},
      {"category":"B", "_count": 1, "value":0.7},
      {"category":"B", "_count": 2, "value":0.2},
      {"category":"B", "_count": 3, "value":1.1},
      {"category":"C", "_count": 1, "value":0.6},
      {"category":"C", "_count": 2, "value":0.1},
      {"category":"C", "_count": 3, "value":0.2}
    ]
  },
  "mark": "line",
  "encoding": {
    "x": {"field": "category"},
    "y": {"field": "value", "type": "quantitative"},
    "color": {"field": "_count"}
  }
}

image

It seems like related to Vega group mark’s “from.facet”; it creates subfacets with “count” which interferes the group_by “count” value. E.g.,:
image

Checklist

  • I checked for duplicate issues.
@domoritz
Copy link
Member

domoritz commented Mar 8, 2024

Yeah, we should use some clear pattern for internal fields. Maybe _{} so here _count. Can you send a pull request to fix this?

@yhoonkim
Copy link
Contributor Author

yhoonkim commented Mar 8, 2024

@domoritz Sorry, I have no capacity to fix this now. If you have any hint for where I/other people should start to look at, it will be super helpful :)

@kanitw
Copy link
Member

kanitw commented Mar 9, 2024

This is probably coming from facet operator in Vega.

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

No branches or pull requests

3 participants