在 vegalite 中设置 x 轴的最大值不能正常工作

set maximum value for x-axis in vegalite doesn't work properly

我想在 vegalite 水平条形图中将我的 x 轴值设置为 0 到 360。这是我的代码:

vegalite({
  width: 600,
  height: 300,
  data: { values: AdPitchedInd },
  mark: 'bar',
  encoding: {
    x: {
      aggregate: "sum",
      field: "occurence",
      type: "quantitative",
      scale: { domain: [0, 360] }
    },
    y: { field: "industry", type: "nominal" },
    color: { field: "ad_pitched", type: "nominal" }
  }
})

我已经设置了 x 轴的比例和域,但它不起作用。我仍然有从 0 到 400 的轴。当我将它更改为 340 时,它可以工作但似乎卡在 360 度...

默认情况下,vega-lite 为指定域选择“漂亮”的视觉边界,这有时甚至可以覆盖明确请求的域。您可以通过在轴刻度内设置 nice=false 来关闭此行为:

vegalite({
  width: 600,
  height: 300,
  data: { values: AdPitchedInd },
  mark: 'bar',
  encoding: {
    x: {
      aggregate: "sum",
      field: "occurence",
      type: "quantitative",
      scale: { domain: [0, 360], nice: false }
    },
    y: { field: "industry", type: "nominal" },
    color: { field: "ad_pitched", type: "nominal" }
  }
})