我正在使用 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"}
}
}
Run Code Online (Sandbox Code Playgroud)
是否可以在此值前面添加一些文本并在其后面放置一个 % 符号?
添加此类复杂注释的最佳方法是使用计算转换;例如:
{
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"}
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1647 次 |
最近记录: |