az5112
az5112

Reputation: 642

Splitting the color legend in a repeat spec in vega

I am using a dataset with the following columns: date, counts, country, engine, and type.

I have created a view with three charts using the repeat operator. The charts show dates on the X axis, counts on Y, and then the bars are split by either country, engine, or type.

I am happy with how things look but I would like to have three separate color legends, one for each domain (so a legend for countries, a legend for type, and a legend for engine). How do I do that?

Here is the link to the editor.

Upvotes: 2

Views: 263

Answers (1)

jakevdp
jakevdp

Reputation: 86310

To have independent color scales & legends, add the following at the top level of the chart specification:

"resolve": {"scale": {"color": "independent"}}

For more information, see https://vega.github.io/vega-lite/docs/resolve.html.

Upvotes: 1

Related Questions