javascript Vega-Lite无法在y轴上的堆叠条形图中正确显示数字

olqngx59  于 12个月前  发布在  Java
关注(0)|答案(1)|浏览(250)

由于某种原因,我的堆积条形图不能正确显示Y轴上的数字。我检查了数据格式,尝试了不同的格式,但它们都是舍入为0.0,0.1等。我的最小值是500,000,最大值是272M。
到哪里去找窃听器?
下面是我的代码:

vegalite({
  width: 600,
  height: 300,
  data: { values: TrafficAp },
  mark: {
    type: "bar",
    size: 35,
    cornerRadiusEnd: 4
  },
  encoding: {
    x: {
      timeUnit: "year_month_day",
      field: "month",
      type: "temporal",
      title: "Month",
      sort: {
        field: "month",
        order: [
          "2022-01",
          "2022-02",
          "2022-03",
          "2022-04",
          "2022-05",
          "2022-06",
          "2023-07",
          "2023-08",
          "2023-09",
          "2023-10",
          "2023-11",
          "2023-12"
        ]
      },
      scale: {
        bandPaddingInner: 0.2 // Adjust the bandPaddingInner value to change the spacing between bars
      }
    },
    y: {
      aggregate: "sum",
      type: "quantitative",
      field: "sessions",
      title: "Sessions",
      axis: {
        format: "s",
        labelExpr:
          "datum.value === 0 ? '0' : format(datum.value, '.1s').replace(/G/,'B')"
      }
    },
    color: {
      field: "traffic_type",
      type: "nominal",
      title: "Traffic Type"
    }
  },
  config: {
    stack: "normalize" // Stack bars vertically and normalize the values
  }
})

字符串
随附的是条形图与

的相似性

uqcuzwp8

uqcuzwp81#

这些是由这条线引起的百分比:

config: {
    stack: "normalize" // Stack bars vertically and normalize the values
  }

字符串
更多信息:https://vega.github.io/vega-lite/docs/stack.html

相关问题