我想通过某个标记的属性(哪一个)为标记规则提供一个名称,然后将其添加到图例中?可以吗?
我需要在图表上提供一些这样的规则,所以在图例上看到它们会很有用。
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {
"values": [
{"X": 1, "Y": 2, "Series": "A"},
{"X": 1, "Y": 3, "Series": "B"},
{"X": 2, "Y": 3, "Series": "A"},
{"X": 2, "Y": 4, "Series": "B"},
{"X": 3, "Y": 4, "Series": "A"},
{"X": 3, "Y": 5, "Series": "B"},
{"X": 4, "Y": 3, "Series": "A"},
{"X": 4, "Y": 4, "Series": "B"},
{"X": 5, "Y": 2, "Series": "A"},
{"X": 5, "Y": 3, "Series": "B"}
]
},
"encoding": {
"x": {"field": "X", "type": "nominal"},
"y": {"field": "Y", "aggregate": "sum", "type": "quantitative"},
"color": {"field": "Series"}
},
"layer":[
{
"mark":"bar"
},
{
"mark": {
"type": "rule",
"stroke": "red",
"strokeWidth": 1,
"strokeDash": [8,4]
},
"encoding":{
"x": {},
"y": {"datum": 6}
}
}
]
}
字符串
Vega Lite编辑器
的数据
1条答案
按热度按时间aemubtdh1#
给你。一旦你的可视化变得更复杂,你可能最好使用Vega而不是VL。
的数据
字符串