有没有办法在直方图的顶部添加一条线?

时间:2020-01-08 19:05:25

标签: vega-lite

到目前为止,我最大的尝试是:Direct link to Vega-editor

我用相同的数据创建了2层,删除了'bar'层的填充,并为'line'层添加了步插值,但是我找不到一种方法来使线条从垂直轴开始并结束在图表的右侧。

规范(对不起,我删除了几行,因为如果文本/代码的比例不够,StackOverflow不想让我发布它):

{
  "$schema": "https://vega.github.io/schema/vega-lite/v4.json",
  "datasets": ...,
  "width": 1130,
  "height": 438,
  "layer": [
    {
      "mark": {
        "type": "bar",
        "opacity": 0.7
      },
      "encoding": {
        "x": {
          "scale": {
            "padding": 0
          },
          "field": "Continent",
          "type": "nominal"
        },
        "y": {
          "field": "Population",
          "type": "quantitative"
        }
      },
      "data": {
        "name": "bar"
      }
    },
    {
      "mark": {
        "type": "line",
        "interpolate": "step",
        "strokeWidth": 3
      },
      "encoding": {
        "x": {
          "axis": {},
          "field": "Continent",
          "type": "nominal"
        },
        "y": {
          "axis": {},
          "field": "Population",
          "type": "quantitative"
        }
      },
      "data": {
        "name": "line"
      }
    }
  ]
}

0 个答案:

没有答案