How to create a scrollable vega visualization

Hi,
I am using Kibana version 7.4
I want help in creating a scrollable vega visualization.
Use Case:
I would like to show only up to 20 tick values in the x-axis of a bar chart, if a user wants to view more than that he has to scroll the vertical bar and view the remaining.

Sample Vega Visualization code

{
  "$schema": "https://vega.github.io/schema/vega/v4.json",
  "data": [
    {
      "name": "table",
      "values": [
        {"category": "A", "amount": 28},
        {"category": "B", "amount": 55},
        {"category": "C", "amount": 43},
        {"category": "D", "amount": 91},
        {"category": "E", "amount": 81},
        {"category": "F", "amount": 53},
        {"category": "G", "amount": 19},
        {"category": "H", "amount": 87},
        {"category": "I", "amount": 28},
        {"category": "J", "amount": 55},
        {"category": "K", "amount": 43},
        {"category": "L", "amount": 91},
        {"category": "M", "amount": 81},
        {"category": "N", "amount": 53},
        {"category": "O", "amount": 19},
        {"category": "P", "amount": 87},
        {"category": "Q", "amount": 28},
        {"category": "R", "amount": 55},
        {"category": "S", "amount": 43},
        {"category": "T", "amount": 91},
        {"category": "U", "amount": 81},
        {"category": "V", "amount": 53},
        {"category": "W", "amount": 19},
        {"category": "X", "amount": 87},
        {"category": "Y", "amount": 87},
        {"category": "Z", "amount": 87},
        {"category": "AA", "amount": 28},
        {"category": "AB", "amount": 55},
        {"category": "AC", "amount": 43},
        {"category": "AD", "amount": 91},
        {"category": "AE", "amount": 81},
        {"category": "AF", "amount": 53},
        {"category": "AG", "amount": 19},
        {"category": "AH", "amount": 87},
        {"category": "AI", "amount": 28},
        {"category": "AJ", "amount": 55},
        {"category": "AK", "amount": 43},
        {"category": "AL", "amount": 91},
        {"category": "AM", "amount": 81},
        {"category": "AN", "amount": 53},
        {"category": "AO", "amount": 19},
        {"category": "AP", "amount": 87},
        {"category": "AQ", "amount": 28},
        {"category": "AR", "amount": 55},
        {"category": "AS", "amount": 43},
        {"category": "AT", "amount": 91},
        {"category": "AU", "amount": 81},
        {"category": "AV", "amount": 53},
        {"category": "AW", "amount": 19},
        {"category": "AX", "amount": 87},
        {"category": "AY", "amount": 87},
        {"category": "AZ", "amount": 87}
      ]
    }
  ],
  "signals": [
    {
      "name": "tooltip",
      "value": {},
      "on": [
        {"events": "rect:mouseover", "update": "datum"},
        {"events": "rect:mouseout",  "update": "{}"}
      ]
    }
  ],
  "scales": [
    {
      "name": "xscale",
      "type": "band",
      "domain": {"data": "table", "field": "category"},
      "range": "width",
      "padding": 0.05,
      "round": true
    },
    {
      "name": "yscale",
      "domain": {"data": "table", "field": "amount"},
      "nice": true,
      "range": "height"
    }
  ],
  "axes": [
    { "orient": "bottom", "scale": "xscale" },
    { "orient": "left", "scale": "yscale" }
  ],
  "marks": [
    {
      "type": "rect",
      "from": {"data":"table"},
      "encode": {
        "enter": {
          "x": {"scale": "xscale", "field": "category"},
          "width": {"value": 30},
          "y": {"scale": "yscale", "field": "amount"},
          "y2": {"scale": "yscale", "value": 0}
        },
        "update": {
          "fill": {"value": "steelblue"}
        },
        "hover": {
          "fill": {"value": "red"}
        }
      }
    },
    {
      "type": "text",
      "encode": {
        "enter": {
          "align": {"value": "center"},
          "baseline": {"value": "bottom"},
          "fill": {"value": "#333"}
        },
        "update": {
          "x": {"scale": "xscale", "signal": "tooltip.category", "band": 0.5},
          "y": {"scale": "yscale", "signal": "tooltip.amount", "offset": -2},
          
          "text": {"signal": "tooltip.amount"},
          "fillOpacity": [
            {"test": "datum === tooltip", "value": 0},
            {"value": 1}
          ]
        }
      }
    }
  ]
}

Thanks in advance

As far as I know its not possible yet.

1 Like

cc @nyuriks - can u please shed more light here ?
Thanks
Rashmi

1 Like

Thank you @kilianten for the reply

My Pleasure!

1 Like

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