I am using Vega and I am stuck on this simple issue. I want to display
The yield is 43.67%
However using the samples provided I have managed to just display the value 43.67
{
  mark:
    {
      type: "text",
      align: "center",
      fontSize: 40,
      fontWeight: "bold"
    },
  encoding: 
    {
      "text": {"field": "Yield", "type": "quantitative",format: ".2f"}
    }
}
Is it possible to add some text in front of this value and put a % sign after it?
THe best way to add this sort of complicated annotation is using a calculate transform; for example:
{
  mark:
    {
      type: "text",
      align: "center",
      fontSize: 40,
      fontWeight: "bold"
    },
  transform:
    [
      {"calculate": "'The yield is ' + datum.Yield + '%'", "as": "annotated_yield"}
    ],
  encoding: 
    {
      "text": {"field": "annotated_yield", "type": "nominal"}
    }
}
In case anyone is wondering how to do this with Vega (instead of Vega-Lite):
  "transform": [
    {"type": "formula", "expr": "'The yield is ' + format(datum.Yield, '.2f') + '%'", "as": "annotated_yield"}
  ]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With