【问题标题】:vega lite Infinite extent for field "field_start": [Infinity, -Infinity]vega lite 字段 \"field_start\" 的无限范围:[Infinity, -Infinity]
【发布时间】:2023-01-11 18:09:26
【问题描述】:

我有堆叠条形图的代码,来自Using Vega Lite to display already-aggregated data 它适用于维加编辑器

{
  "data": {
    "values": [
      {"bin": "[-inf,8.0)", "bad_distr": 0.009210526315789473, "good_distr": 0.07763157894736843},
      {"bin": "[8.0,14.0)", "bad_distr": 0.075, "good_distr": 0.21842105263157896},
      {"bin": "[14.0,16.0)", "bad_distr": 0.009210526315789473, "good_distr": 0.05394736842105263},
      {"bin": "[16.0,44.0)", "bad_distr": 0.16052631578947368, "good_distr": 0.3236842105263158},
      {"bin": "[44.0,inf)", "bad_distr": 0.04078947368421053, "good_distr": 0.031578947368421054}
    ]
  },
  "transform": [
    {"fold": ["bad_distr", "good_distr"], "as": ["bad", "good"]}
  ],
  "mark": {"type": "bar"},
  "encoding": {
    "y": {"type": "ordinal", "field": "bin"},
    "x": {"type": "quantitative", "field": "good"},
    "color": {"type": "nominal", "field": "bad"}
  }
}

情节很好

相同的数据,我在弹性数据库中,

相同的代码发出警告并且情节没有出现

{
  "$schema": "https://vega.github.io/schema/vega-lite/v2.4.json",
  "title": {
    "text":  "Bin Plot",
    "fontSize":14
  },
  "data": {
    "url" : {
        "index": "scorecard_bin_plot",
        "body": {
          "size":10000,
          "_source": ["bin","good_distr","bad_distr"]
        }
      }  
      "format": {"property": "hits.hits"},
  },
  "transform": [
    {"fold": ["_source.bad_distr", "_source.good_distr"], "as": ["bad", "good"]}
  ],
  "mark": {"type": "bar"},
  "encoding": {
    "y": {"type": "ordinal", "field": "_source.bin"},
    "x": {"type": "quantitative", "field": "good"},
    "color": {"type": "nominal", "field": "bad"}
  }
}

我不明白这个问题

使用弹性和 kibana 7.12.0

【问题讨论】:

  • 你好 Mr.Negative Voting Genius,为什么这是反对票?这是一个糟糕的问题,还是您不知道答案? stack overflow是只给无所不知的人,还是只给想知道的人
  • 你为什么删除你的评论?
  • 你能告诉我你是如何在你的麋鹿集群中获得这些数据的吗?我正在尝试重现同样的问题
  • 你解决了这个问题吗?如果你解决了,请分享给我!

标签: kibana elastic-stack vega-lite


【解决方案1】:

当使用 Vega 而不是 Lite,使用来自 Elastic 而不是硬编码的数据时,似乎在转换函数中新字段应该被称为“数据”并从格式函数中的字段中获取数据。喜欢:

"format": {"property": "data_from_elastic"},
"transform": [{"type": "someType", "field":"data"}]

也许你可以在"property"中使用_source,称它为data,下面将其用作data.good_distrdata.bad_distr

【讨论】:

    猜你喜欢
    • 2020-08-14
    • 1970-01-01
    • 1970-01-01
    • 2011-11-17
    • 1970-01-01
    • 1970-01-01
    • 2015-12-24
    • 1970-01-01
    • 2020-09-03
    相关资源
    最近更新 更多