我有堆叠条形图的代码,从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
1条答案
按热度按时间ubby3x7f1#
当使用Vega而非Lite时,数据来自Elastic而非硬编码,似乎在转换函数中新字段应称为“data”,并从格式函数中的字段获取数据。
也许您可以在
"property"
中使用_source
,称之为data
,并在下面将其用作data.good_distr
和data.bad_distr
。