0

I am having a hard time figuring out how to build a multiview chart in Vega using aggregated/nested.

I believe it is related to the way I am trying to transform my data to use in Vega multi view chart. Can anyone give me a hand to understand this?

I know flatten transformation is working as debug shows

image

But what I get is this

capture10

This is what I would like to achieve

capture

This is my schema to build the chart

{
  "$schema": "https://vega.github.io/schema/vega/v3.json",
  "width": 400,
  "height": 200,
  "padding": 5,
  "data": [
    {
      "name": "source",
      "values": {
        "aggregations": {
          "order_labels": {
            "buckets": [
              {
                "key": "USD/CAD",
                "doc_count": 1,
                "orders": {
                  "doc_count": 40,
                  "orders_id": {
                    "buckets": [
                      {
                        "key": 5241,
                        "doc_count": 1,
                        "orders_price": {"value": 0.01991}
                      },
                      {
                        "key": 5242,
                        "doc_count": 1,
                        "orders_price": {"value": 0.02021}
                      }
                    ]
                  }
                }
              },
              {
                "key": "CAD/COD",
                "doc_count": 1,
                "orders": {
                  "doc_count": 40,
                  "orders_id": {
                    "buckets": [
                      {
                        "key": 5041,
                        "doc_count": 1,
                        "orders_price": {"value": 0.00002953}
                      },
                      {
                        "key": 5042,
                        "doc_count": 1,
                        "orders_price": {"value": 0.00002971}
                      }
                    ]
                  }
                }
              }
            ]
          }
        }
      },
    "format": {"property": "aggregations.order_labels.buckets"},
    "transform": [
      {
        "type": "flatten",
        "fields": ["orders.orders_id.buckets"],
        "as": ["orders"]
      }
    ]
  }
  ],
  "mark": "bar",
  "encoding": {
    "row": {
      "field": "orders.key",
      "type": "ordinal"
    },
    "x": {
      "aggregate": "sum",
      "field": "orders.orders_price.value",
      "type": "quantitative",
      "scale": { "zero": false }
    },
    "y": {
      "field": "key",
      "type": "ordinal",
      "scale": { "rangeStep": 12 }
    }
  }
}

I did many things but can`t understand what is wrong with it

Guid
  • 123
  • 2
  • 17
  • 1
    I think kibana only supports v2 which doesn't appear to have flatten transofrm as seen in the docs here https://github.com/vega/vega/wiki/Data-Transforms – sramalingam24 May 18 '18 at 19:49

1 Answers1

0

Kibana 6.4 supports flatten transform for sure. I think it was also supported in 6.3.

Yuri Astrakhan
  • 8,808
  • 6
  • 63
  • 97