Vega lite - 访问 'repeat' 变量以用作过滤器

Vega lite - accessing 'repeat' variable to use as filter

我正在尝试制作格状条形图,每个图表后面隐约显示总计 - 参见此图。

我已经成功地创建了一个冗长的规范,但我想通过使用 'repeat' 和过滤器使它更简洁。 Here 是工作版本。

Here 是我的版本,几乎可以工作,但我不知道如何让过滤器访问 'repeat' 变量。

如何访问 'repeat' 中指定的变量以正确过滤数据?

我尝试了以下方法,但它不起作用

 { 
  "transform": [
     {"filter": "datum.gender == repeat"}
   ]
 }

目前不支持:https://github.com/vega/vega-lite/issues/2518. These kinds of use cases where you can reuse parts will work much better in DSLs like Altair. JSON is unfortunately not a good fit for reuse. As a side note, a succinct spec is not faster than the verbose spec you wrote. However, I understand that it would be easier to read. Another related proposal for shorter specs is: https://github.com/vega/vega-lite/issues/3384