簡體   English   中英

Vega-lite x軸顯示指定數量的數據

[英]The Vega-lite x-axis displays the specified number of data

在此處輸入圖像描述

這是我生成的圖片,我的 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"
    }
  }
}

沒有實際數據很難調試,但如果將其更改為臨時數據會怎樣?

"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"}
      }
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM