【发布时间】:2020-12-18 16:31:36
【问题描述】:
【问题讨论】:
标签: plot text label data-visualization vega-lite
【问题讨论】:
标签: plot text label data-visualization vega-lite
您可以通过将条形标记和文本标记分层来做到这一点。例如(open in editor):
{
"data": {"url": "data/barley.json"},
"width": 400,
"encoding": {
"x": {
"type": "quantitative",
"aggregate": "sum",
"field": "yield",
"stack": "zero"
},
"y": {"type": "nominal", "field": "variety"}
},
"layer": [
{
"mark": "bar",
"encoding": {"color": {"type": "nominal", "field": "site"}}
},
{
"mark": {"type": "text", "color": "white", "dx": -15, "dy": 3},
"encoding": {
"detail": {"type": "nominal", "field": "site"},
"text": {
"type": "quantitative",
"aggregate": "sum",
"field": "yield",
"format": ".1f"
}
}
}
]
}
【讨论】: