vega lite/kibana-区域标记不显示任何值

wd2eg0qa  于 2021-06-13  发布在  ElasticSearch
关注(0)|答案(1)|浏览(408)

我有一个非常简单的问题,但我是一个全新的织女星/织女星lite和教程的例子没有帮助我解决我的问题。
当我试图只显示浮点值时,mark:point/bar似乎有效。所有其他需要相邻点之间连接的东西似乎都失败了,比如“区域”或“线”。
为了将我的值连接到面积图,我遗漏了什么?聚合?层?时间戳值计算错误吗?

{
  "$schema": "https://vega.github.io/schema/vega-lite/v4.json",
  "data": {
    "url": {
      "%context%": true,
      "%timefield%": "@timestamp",
      "index": "default-*",
      "body": {"size": 10000, "_source": ["@timestamp", "numericData"]}
    },
    "format": {"property": "hits.hits"}
  },
  "transform": [
    {"calculate": "toDate(datum._source['@timestamp'])", "as": "time"}
  ],
  "vconcat": [
    {
      "width": 1200,
      "mark": {"type": "area", "line": true, "point": true},
      "encoding": {
        "x": {
          "field": "time",
          "scale": {"domain": {"selection": "brush"}},
          "type": "temporal",
          "axis": {"title": ""}
        },
        "y": {
          "field": "_source.numericData",
          "type": "quantitative",
          "scale": {"domain": [0, 10]}
        }
      }
    },
    {
      "width": 1200,
      "height": 60,
      "mark": {"type": "area", "line": true, "point": true},  // <-- only points are rendered :(
      "selection": {"brush": {"type": "interval", "encodings": ["x"]}},
      "encoding": {
        "x": {"field": "time", "type": "temporal"},
        "y": {
          "field": "_source.numericData",
          "type": "quantitative",
          "formatType": "String",
          "axis": {"tickCount": 3, "grid": false}
        }
      }
    }
  ]
}

点是可见的-值在那里,但该地区没有得到渲染,因为,我怀疑,我需要告诉织女星lite解释的数字浮点值在y上要解释整个时间场。

esyap4oy

esyap4oy1#

你没有分享你的数据,所以我只能猜测为什么会这样。但您可能看到此结果的一个原因是,如果数据中散布有空值。下面是一个简单的示例(在编辑器中打开):

{
  "data": {
    "values": [
      {"x": 1, "y": 1},
      {"x": 2, "y": null},
      {"x": 3, "y": 2},
      {"x": 4, "y": null},
      {"x": 5, "y": 3},
      {"x": 6, "y": null}
    ]
  },
  "mark": {"type": "area", "point": true, "line": true},
  "encoding": {
    "x": {"field": "x", "type": "quantitative"},
    "y": {"field": "y", "type": "quantitative"}
  }
}


与桥不同,线和面积不是通过单个值定义的,而是通过相邻值定义的。因为没有相邻的非空值对,所以没有绘制线或区域的位置。
如果是这种情况,可以使用适当的过滤器转换(在编辑器中打开)删除空点:

{
  "data": {
    "values": [
      {"x": 1, "y": 1},
      {"x": 2, "y": null},
      {"x": 3, "y": 2},
      {"x": 4, "y": null},
      {"x": 5, "y": 3},
      {"x": 6, "y": null}
    ]
  },
  "transform": [{"filter": "isValid(datum.y)"}],
  "mark": {"type": "area", "point": true, "line": true},
  "encoding": {
    "x": {"field": "x", "type": "quantitative"},
    "y": {"field": "y", "type": "quantitative"}
  }
}

相关问题