没有相应数据时强制使用图例

force a legend when there is no corresponding data

我希望得到关于如何在图例中包含一个项目的指示,尽管它不在数据中——我试图通过排序的方式添加它,但似乎没有工作---editor link。在这个例子中,我希望 "Not helpful" 出现在图例中,尽管它没有出现在任何响应中。

我知道这在某种程度上违背了整个视觉编码概念,但我认为该用例是有效的。

感谢您的帮助!

您可以通过指定比例域来做到这一点:

"scale": {
  "domain": [
    "Extremely helpful",
    "Very helpful",
    "Somewhat helpful",
    "Not so helpful",
    "Not helpful"
  ]
}

结果如下所示 (view in editor):