Wrapped Facet in vega

Hello,

I have used facet as well as layer in below code, I tried to limit no. of columns to 2 but it wasn't working.

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "name": "trellis_barley",
  "description": "The Trellis display by Becker et al. helped establish small multiples as a “powerful mechanism for understanding interactions in studies of how a response depends on explanatory variables”. Here we reproduce a trellis of Barley yields from the 1930s, complete with main-effects ordering to facilitate comparison.",
  "data": {"url": "data/barley.json"},
   "facet": {
    
     "field": "site",
      "type": "ordinal",
     "columns":2   
    },
    "spec":{
  "layer":[{
  "mark": "point",
  "height": {"step": 12},
  "encoding": {
    "y": {
      "aggregate": "median",
      "field": "yield",
      "type": "quantitative",
      "scale": {"zero": false}
    },
    "x": {"field": "variety", "type": "ordinal", "sort": "-x"},
    "color": {"field": "year", "type": "nominal"}
  }
  },
  {
  "mark": "line",
  "height": {"step": 12},
  "encoding": {
    "y": {
      "aggregate": "sum",
      "field": "yield",
      "type": "quantitative",
      "scale": {"zero": false}
    },
    "x": {"field": "variety", "type": "ordinal", "sort": "-x"},
    "color": {"value": "#000000"}
  }
  }] ,"resolve": {"axis": { "y": "independent"}}},
  "resolve": {
        "scale": {"y": "independent"},
        "axis": {"y": "independent"}
    }
}

output :

I require the output in this manner, where data is wrapped in 2 columns. Any suggestions on how can I get it ?

Hi @Pranusha119 ,

These kinds of problems aren't generally at the level of Kibana, but actually at the Vega library itself.

I recommend using the Vega editor to figure out the issue, as you can see here.

Once I pasted in your code, the editor showed me the problem - the colums field belongs on the root object, not under facet.
If you look at the link above, you'll see it works. :slight_smile:

Kibana is just providing a wrapper around Vega, so in general you'll find it helpful to start at that level and work your way down. :smiley:

Thanks @gmmorris

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.