使用Vega Lite实现交替条纹的可视化效果,以下是示例代码:
{
"data": {
"values": [
{"category": "A", "value": 25},
{"category": "B", "value": 40},
{"category": "C", "value": 30},
{"category": "D", "value": 15}
]
},
"layer": [
{
"mark": {"type": "bar", "color": "white", "fillOpacity": 0.5},
"encoding": {
"y": {"field": "category", "type": "nominal", "axis": null},
"x": {"field": "value", "type": "quantitative", "axis": null},
"opacity": {"field": "index", "type": "nominal", "scale": {"range": [0,1]}, "legend": null},
"tooltip": [{"field": "value", "type": "quantitative"}]
}
},
{
"mark": {"type": "bar", "color": "black", "fillOpacity": 0.5},
"encoding": {
"y": {"field": "category", "type": "nominal", "axis": null},
"x": {"field": "value", "type": "quantitative", "axis": {"title": "Value"}},
"opacity": {"value": 0, "legend": null}
}
}
]
}