英文:
How to enable mouse click even on legend with repeat configuration
问题
我正在使用重复配置,并且可以使用此配置绘制多个系列。但是,当我尝试设置参数并尝试与图例绑定时,它会报“重复信号”的错误。我还在使用 Spec 配置。感谢您提前的帮助。
英文:
i am using repeat configuration and i could able to draw multiple series using this configuration. However when i try to set the params and try to bind with legend, it gives error duplicate signal. I am also using Spec configuration.
Appreciate your help in advance
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {"url": "data/movies.json"},
"repeat": {"layer": ["US Gross", "Worldwide Gross"]},
"spec": {
"mark": "line",
"encoding": {
"x": {"bin": true, "field": "IMDB Rating", "type": "quantitative"},
"y": {
"aggregate": "mean",
"field": {"repeat": "layer"},
"type": "quantitative",
"title": "Mean of US and Worldwide Gross"
},
"color": {"datum": {"repeat": "layer"}, "type": "nominal"}
}
}
}
答案1
得分: 1
以下是您要的翻译内容:
正如我在上面的评论中指出的,当结合"params"
与使用"layer"
的"repeat"
视图组合时,似乎存在已知的 bug(GitHub 链接)。
考虑到这一点,您需要重新设计您的规范以实现所需的结果。以下是一个基于您提供的示例的样本(示例链接)。关键的方法是使用"fold"
转换,从"US Gross"
和"Worldwide Gross"
创建新的"key"
和"value"
字段。通过这个变化,这两行现在可以在单个图层中显示,并且交互式图例现在可以正常工作。
英文:
As noted in my comment above, there appears to be a known bug when combining "params"
with a "repeat"
view composition that uses "layer"
in particular (GitHub link).
With this in mind, you'll need to refactor your specification to achieve the desired result. Here is a sample based on your provided example (example link). The key approach here is to use a "fold"
transform to create new "key" and "value" fields from "US Gross" and "Worldwide Gross". With this change, the two lines can now be displayed within a single layer, and the interactive legend will now work.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论