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

bar charts with ordinal x-axis cannot use log-scale on y-axis #7993

Closed
pdhorn opened this issue Feb 17, 2022 · 3 comments · Fixed by #7997
Closed

bar charts with ordinal x-axis cannot use log-scale on y-axis #7993

pdhorn opened this issue Feb 17, 2022 · 3 comments · Fixed by #7997
Labels

Comments

@pdhorn
Copy link

pdhorn commented Feb 17, 2022

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "description": "Google's stock price over time.",
  "data": {
    "values": [
      {"y": 2, "x": 1},
      {"y": 7, "x": 3},
      {"y": 4, "x": 4},
      {"y": 1, "x": 6},
      {"y": 8, "x": 8},
      {"y": 3, "x": 9},
      {"y": 5, "x": 10}
    ]
  },
  "mark": "bar",
  "encoding": {
    "x": {"field": "x", "type": "ordinal"},
    "y": {"field": "y", "type": "quantitative", "scale": {"type": "log"}}
  }
}

Is trying to use a log scale on the y-axis, with an ordinal x-axis. This produces a blank chart:

Screen Shot 2022-02-17 at 10 54 59 AM

Note, changing encoding.x.type to quantitative produces a reasonable chart with very skinny bars. Alternatively, removing the encoding.y.scale (and leaving x as ordinal) produces a bar chart with thicker bars.

I would like to have the ordinal x-axis / thick bars with the y-axis on a log scale.

@pdhorn
Copy link
Author

pdhorn commented Feb 17, 2022

This also fails when the x-axis is temporal

@domoritz
Copy link
Member

There is a warning in the editor "Cannot stack non-linear scale (log).". The problem is that stacked data cannot be on a log scale.

You need to disable stacking: Open the Chart in the Vega Editor.

I think we should disable automatic stacking when the scale is log.

@pdhorn
Copy link
Author

pdhorn commented Feb 19, 2022

Thanks for the tip and the fix @domoritz !

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.

2 participants