如何在单行显示中组合文本和字段值

How to combine text and a field value in a single line of display

我正在使用 Vega,但我被困在这个简单的问题上。我要显示

The yield is 43.67%

但是使用提供的样本我设法只显示值 43.67

{
  mark:
    {
      type: "text",
      align: "center",
      fontSize: 40,
      fontWeight: "bold"
    },
  encoding: 
    {
      "text": {"field": "Yield", "type": "quantitative",format: ".2f"}
    }
}

是否可以在该值前面添加一些文字并在其后放置一个 % 符号?

添加这种复杂注释的最佳方法是使用 calculate transform;例如:

{
  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"}
    }
}