title: How to create a stacked bar chart with values in Vega?
body: <p>I'm creating a custom visualization in Vega for Kibana. It should display vertical stacked bars and their values in numbers.
  The "y" axis is the doc count and the "x" axis a time scale.</p>
  
  <p>I'm not familiar with Vega and I first tried to display numbers on simple bars. I copy/pasted, tweeked some parameters and had this version :</p>
  
  <pre><code>    "marks": [
          {
              "type": "group",
              "marks": [
                  {
                      "type": "rect",
                      "name": "bars",
                      "from": {"data":"table"},
                      "encode": {
                          "enter": {
                              "x": {"scale": "xbars", "field": "key"},
                              "width": {"scale": "xbars", "band": 1},
                              "y": {"scale": "yscale", "field": "doc_count"},
                              "y2": {"scale": "yscale", "value": 0}
                          }
                      }
                  },
                  {
                      "type": "text",
                      "from": {"data": "bars"},
                      "align": "center",
                      "encode": {
                          "enter": {
                              "y": {"field": "y", "offset": -5},
                              "x": {"field": "x", "offset": 0},
                              "text": {"field": "datum.doc_count"}
                          }
                      }
                  }
              ]
          }
      ]
  </code></pre>
  
  <p>The result displays simple bars, numbers, the time format is good.</p>
  
  <p>I used a "y"and a "y2" to be able to display both bars and text, but I can't add anymore "y" axis ("y3", "y4"...).
  Idon't even know if it's possible to do what I want.</p>
  
  <p>It want the chart to look like this example but with numbers :
  <a href="https://vega.github.io/vega/examples/stacked-bar-chart/" rel="nofollow noreferrer">https://vega.github.io/vega/examples/stacked-bar-chart/</a></p>