我正在尝试重现本教程 https://nyurik.github.io/Vega-Trends-Graph-for-Kibana/
虽然 spec 在 kibana-vega 插件(kibana 版本 6.3.0)中呈现,但完全相同的 sepc 不会在 vega 在线编辑器中呈现任何可视化。vega embed 没有引发任何错误,并且数据查看器看起来数据已正确处理。
vega 嵌入带有规范的在线编辑器
{
"$schema": "https://vega.github.io/schema/vega/v3.0.json",
"data": [
{
"name": "values",
"values" : [{"key_as_string":"2018-08-15T16:22:00.000Z","key":1534350120000,"doc_count":0},{"key_as_string":"2018-08-15T16:23:00.000Z","key":1534350180000,"doc_count":3},{"key_as_string":"2018-08-15T16:24:00.000Z","key":1534350240000,"doc_count":11},{"key_as_string":"2018-08-15T16:25:00.000Z","key":1534350300000,"doc_count":9},{"key_as_string":"2018-08-15T16:26:00.000Z","key":1534350360000,"doc_count":10},{"key_as_string":"2018-08-15T16:27:00.000Z","key":1534350420000,"doc_count":8},{"key_as_string":"2018-08-15T16:28:00.000Z","key":1534350480000,"doc_count":5},{"key_as_string":"2018-08-15T16:29:00.000Z","key":1534350540000,"doc_count":4},{"key_as_string":"2018-08-15T16:30:00.000Z","key":1534350600000,"doc_count":7},{"key_as_string":"2018-08-15T16:31:00.000Z","key":1534350660000,"doc_count":8},{"key_as_string":"2018-08-15T16:32:00.000Z","key":1534350720000,"doc_count":11},{"key_as_string":"2018-08-15T16:33:00.000Z","key":1534350780000,"doc_count":6},{"key_as_string":"2018-08-15T16:34:00.000Z","key":1534350840000,"doc_count":6},{"key_as_string":"2018-08-15T16:35:00.000Z","key":1534350900000,"doc_count":8},{"key_as_string":"2018-08-15T16:36:00.000Z","key":1534350960000,"doc_count":4},{"key_as_string":"2018-08-15T16:37:00.000Z","key":1534351020000,"doc_count":12},{"key_as_string":"2018-08-15T16:38:00.000Z","key":1534351080000,"doc_count":8},{"key_as_string":"2018-08-15T16:39:00.000Z","key":1534351140000,"doc_count":8},{"key_as_string":"2018-08-15T16:40:00.000Z","key":1534351200000,"doc_count":7},{"key_as_string":"2018-08-15T16:41:00.000Z","key":1534351260000,"doc_count":9}],
"transform": [
{
"type": "window",
"ops": [
"row_number"
],
"as": [
"row_number"
]
},
{
"type": "formula",
"expr": "floor((datum.row_number-1)/10)",
"as": "group"
},
{
"type": "aggregate",
"groupby": [
"group"
],
"ops": [
"sum"
],
"fields": [
"doc_count"
],
"as": [
"count"
]
}
]
},
{
"name": "results",
"values": [
{}
],
"transform": [
{
"type": "formula",
"expr": "data('values')[0].count",
"as": "last"
},
{
"type": "formula",
"expr": "data('values')[1].count",
"as": "prev"
},
{
"type": "formula",
"expr": "datum.last>datum.prev",
"as": "up"
},
{
"type": "formula",
"expr": "datum.last<datum.prev",
"as": "down"
},
{
"type": "formula",
"expr": "if(datum.last==0, if(datum.prev==0,0,-1), (datum.last-datum.prev)/datum.last)",
"as": "percentChange"
},
{
"type": "formula",
"expr": "if(datum.up,':)',if(datum.down,':(','-'))",
"as": "symbol"
}
]
}
],
"marks": [
{
"type": "text",
"from": {
"data": "results"
},
"encode": {
"update": {
"text": {
"signal": "datum.symbol + ' ' + datum.last + ' ('+ format(datum.percentChange, '+.1%') + ')'"
},
"fill": {
"signal": "if(datum.up, '#00ff00', if(datum.down, '#ff0000', '#0000ff'))"
},
"align": {
"value": "center"
},
"baseline": {
"value": "middle"
},
"xc": {
"signal": "width/2"
},
"yc": {
"signal": "height/2"
},
"fontSize": {
"signal": "min(width/10, height)/1.3"
}
}
}
}
]
}