删除Vega Lite日期X轴中的小刻度

时间:2019-12-04 05:58:59

标签: vega-lite

我具有以下Vega Lite规格

{
  "config": {
    "view": {"stroke": "transparent"},
    "mark": {"tooltip": null},
    "axis": {
      "grid": false,

      "labelAngle": 0,
      "labelFont": "museo-sans-300",
      "labelFontSize": 15,
      "labelFontWeight": "normal",
      "titleFont": "museo-sans-300",
      "titleFontSize": 15,
      "titleFontWeight": "normal"
    }
  },
  "$schema": "https://vega.github.io/schema/vega-lite/v4.json",
  "data": {"name": "data"},
  "mark": {
    "type": "line",
    "interpolate": "monotone",
    "point": {"filled": false, "fill": "white"}
  },
  "encoding": {
    "x": {
      "field": "date",
      "type": "temporal",
      "timeUnit": "monthdate",
      "axis": {"title": null,"tickMinStep": 1}
    },
    "y": {"type": "quantitative", "field":"%"},
    "color": {
      "field": "metric",
      "type": "nominal",
      "legend": {
        "labelFont": "museo-sans-300",
        "labelFontSize": 15,
        "title": null,
        "offset": 0,
        "padding": 0
      }
    }
  },
  "width": 500,
  "datasets": {
    "data": [
      {
        "date": "2019-11-28",
        "metric": "linehaul_util_perc",
        "%": 48.36678571428571
      },
      {
        "date": "2019-11-29",
        "metric": "linehaul_util_perc",
        "%": 57.74388888888889
      },
      {"date": "2019-12-03", "metric": "linehaul_util_perc", "%": 57.25},
      {
        "date": "2019-12-04",
        "metric": "linehaul_util_perc",
        "%": 71.37883720930233
      },
      {"date": "2019-11-28", "metric": "recovery_perc", "%": 62.7},
      {"date": "2019-11-29", "metric": "recovery_perc", "%": 63.1},
      {"date": "2019-12-02", "metric": "recovery_perc", "%": 126.1},
      {"date": "2019-12-03", "metric": "recovery_perc", "%": 80.4},
      {"date": "2019-12-04", "metric": "recovery_perc", "%": 60.4},
      {"date": "2019-11-28", "metric": "rolling_recovery", "%": 73.9},
      {"date": "2019-11-29", "metric": "rolling_recovery", "%": 73.3},
      {"date": "2019-11-30", "metric": "rolling_recovery", "%": 71.5},
      {"date": "2019-12-01", "metric": "rolling_recovery", "%": 72.2},
      {"date": "2019-12-02", "metric": "rolling_recovery", "%": 76.5},
      {"date": "2019-12-03", "metric": "rolling_recovery", "%": 76.6},
      {"date": "2019-12-04", "metric": "rolling_recovery", "%": 75.5}
    ]
  }
}

哪个产生以下图像

enter image description here

这是正确的,除了我只希望在带有文字的日子里显示刻度线(即主要刻度线)。将最小刻度距离设置为1似乎不起作用,尽管我可以使用tickCount进行更改。但是,这将需要一些额外的逻辑才能首先确定集合中的天数,因此能够做到这一点很棒。

1 个答案:

答案 0 :(得分:0)

事实证明,我只是没有足够仔细地阅读文档。使用tickCount可以解决此问题,因为它可以将'day'作为参数,这是我所需要的。