【问题标题】:Grid with Pre-Binned Data具有预分箱数据的网格
【发布时间】:2021-01-29 04:52:02
【问题描述】:

有了"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"},
    {"calculate": "timeOffset('hours', datum.day, 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", "value": 5},
      {"day": "2021-01-05T00:00:00", "value": 4},
      {"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", "value": 3},
      {"day": "2021-01-13T00:00:00", "value": 5},
      {"day": "2021-01-15T00:00:00", "value": 3}
    ]
  }}

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

【问题讨论】:

    标签: vega-lite vega


    【解决方案1】:

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

    { "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},
          "encoding": {
            "x": {
              "type": "temporal",
              "field": "start",
              "axis": {"grid": true}
            },
            "y": {
              "field": "value",
              "axis": {"grid": true},
              "type": "quantitative"}
          }
        }
      ],
      "transform": [
        {"calculate": "toDate(datum.day)", "as": "day"},
        {"calculate": "timeOffset('hours', datum.day, -12)", "as": "start"},
        {"calculate": "timeOffset('hours', datum.day, 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", "value": 5},
          {"day": "2021-01-05T00:00:00", "value": 4},
          {"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", "value": 3},
          {"day": "2021-01-13T00:00:00", "value": 5},
          {"day": "2021-01-15T00:00:00", "value": 3}
        ]
      }
    }
    

    【讨论】:

      【解决方案2】:

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

      • #7192 fix: ("bin":"binned") 时允许轴设置

      【讨论】:

        猜你喜欢
        • 2020-09-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-03-11
        • 2016-04-02
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多