elasticsearch Vega-lite x轴显示指定数量的数据

cpjpxq1n  于 2023-02-07  发布在  ElasticSearch
关注(0)|答案(1)|浏览(129)

这是我生成的图片,我的x轴太大了,所以如果我想显示指定的数字,我如何修复我的代码?
我试图从ES DSL中削减我的数据源作为我的突破点,但cumulative_sum需要完整的数据源。

{
  "$schema": "https://vega.github.io/schema/vega-lite/v2.json",
  "data": {
    "url": {
      "index": "x-*",
      "body": {
        "query": {"match_all": {}},
        "size": 0,
        "aggs": {
          "group_by_date": {
            "date_histogram": {
              "field": "timestamp",
              "interval": "day"
            },
            "aggs": {
              "cumulative_docs": {
                "cumulative_sum": {"buckets_path": "_count"}
              }
            }
          }
        }
      }
    },
    "format": {
      "property": "aggregations.group_by_date.buckets"
    }
  },
  "width": "container",
  "height": 1200,
  "layer": [
    {
    "mark": {
        "type": "line",
        "point": {"filled": false, "fill": "black"}
      }
    },
    {
      "mark": {
        "type": "text",
        "align": "left",
        "baseline": "middle",
        "fontSize": 15
      },
      "encoding": {
        "text": {"field": "cumulative_docs.value", "type": "quantitative"}
      }
    }
  ],
  "encoding": {
    "x": {
      "axis": {"title": "date"},
      "field": "key_as_string",
      "type": "nominal"
    },
    "y": {
      "aggregate": "y",
      "axis": {"title": "project_num"},
      "field": "cumulative_docs.value",
      "type": "quantitative",
      "stack": "normalize"
    }
  }
}
8qgya5xd

8qgya5xd1#

没有实际数据很难进行调试,但是如果将其更改为时态数据会发生什么情况?

"x": {
      "axis": {"title": "date"},
      "field": "key_as_string",
      "type": "temporal"
    },

编辑
删除本节。

{
      "mark": {
        "type": "text",
        "align": "left",
        "baseline": "middle",
        "fontSize": 15
      },
      "encoding": {
        "text": {"field": "cumulative_docs.value", "type": "quantitative"}
      }
    }

相关问题