具有预装箱数据的网格

问题描述

通过 "bin": "binned",我可以使用预先分箱的数据。如何启用网格?似乎在 vega-lite 到 vega 的转换过程中,我的 grid 设置被覆盖为 false

{ "mark": "bar","encoding": {
    "x": {
      "type": "temporal","bin": "binned","field": "start","axis": {"grid": true}
    },"x2": {"field": "end"},"y": {"type": "quantitative","field": "value"}
  },"transform": [
    {"calculate": "toDate(datum.day)","as": "day"},{"calculate": "timeOffset('hours',datum.day,-12)","as": "start"},12)","as": "end"}
  ],"height": 250,"width": 800,"$schema": "https://vega.github.io/schema/vega-lite/v4.json","data": {
    "values": [
      {"day": "2021-01-01T00:00:00","value": 5},{"day": "2021-01-02T00:00:00","value": 4},{"day": "2021-01-04T00:00:00",{"day": "2021-01-05T00:00:00",{"day": "2021-01-09T00:00:00","value": 1},{"day": "2021-01-10T00:00:00","value": 3},{"day": "2021-01-11T00:00:00","value": 2},{"day": "2021-01-12T00:00:00",{"day": "2021-01-13T00:00:00",{"day": "2021-01-15T00:00:00","value": 3}
    ]
  }}

如果没有schema解决方案,是否可以通过view api重新启用网格?

解决方法

嗯,这太可怕了。使用匹配的编码和透明的所有标记对垃圾图进行分层。希望有人有更好的解决方案。

{ "layer": [
    {
      "mark": "bar","encoding": {
        "x": {
          "type": "temporal","bin": "binned","field": "start","axis": {"grid": true},"title": "day"
        },"x2": {"field": "end"},"y": {"type": "quantitative","field": "value"}
      }
    },{
      "mark": {"type": "point","opacity": 0},"axis": {"grid": true}
        },"y": {
          "field": "value","type": "quantitative"}
      }
    }
  ],"transform": [
    {"calculate": "toDate(datum.day)","as": "day"},{"calculate": "timeOffset('hours',datum.day,-12)","as": "start"},12)","as": "end"}
  ],"height": 250,"width": 800,"$schema": "https://vega.github.io/schema/vega-lite/v4.json","data": {
    "values": [
      {"day": "2021-01-01T00:00:00","value": 5},{"day": "2021-01-02T00:00:00","value": 4},{"day": "2021-01-04T00:00:00",{"day": "2021-01-05T00:00:00",{"day": "2021-01-09T00:00:00","value": 1},{"day": "2021-01-10T00:00:00","value": 3},{"day": "2021-01-11T00:00:00","value": 2},{"day": "2021-01-12T00:00:00",{"day": "2021-01-13T00:00:00",{"day": "2021-01-15T00:00:00","value": 3}
    ]
  }
}
,

这是解决此问题的拉取请求。可能不会导致任何结果。

  • #7192 修复:当 ("bin":"binned") 时允许轴设置