Setting a maximum axis value in Vega lite
Asked Answered
A

1

11

I'm trying to make a simple stacked bar chart, only on the X axis. I have it working, with two values of 50, and 250. So the max of the X axis shows as 300.

How do I force that to another value, like 500? So there is a gap from the last value, to the end of the axis?

In assuming it is via a scale domain somehow? I'm having a tough time understanding all of the options.

Atal answered 13/3, 2019 at 3:53 Comment(1)
Can you show an example of the spec you are using, and what you have tried?Institutor
I
17

You can set the axis limits using the scale domain. Here is an example (vega editor link):

{
  "data": {"values": [{"x": 50, "c": 1}, {"x": 250, "c": 2}]},
  "mark": "bar",
  "encoding": {
    "x": {"field": "x", "type": "quantitative", "scale": {"domain": [0, 500]}},
    "color": {"field": "c", "type": "ordinal"}
  }
}

enter image description here

Institutor answered 13/3, 2019 at 4:2 Comment(1)
Thank you! I was on the right path apparently, but just wasn't putting it in the right place.Atal

© 2022 - 2024 — McMap. All rights reserved.