Reputation: 685
Is there a way to make the labels in a legend with horizontal direction wrap? I made a simple example wtih the cars dataset where i transformed the categtories to generate longer strings in the Vega Editor:
Suppose I have more categories but also want to put the legend at the top/bottom to provide more horizontal space for the chart area.
Upvotes: 2
Views: 1138
Reputation: 3225
Use the columns
property of legend
:
{
"legend": {
"orient": "top",
"direction": "horizontal",
"columns": 2
}
Upvotes: 1
Reputation: 685
I've created a custom legend in a separate div
.
The categories and their mapped colors in the Vega visualization can be accessed via the View API:
const colors = vegaView.scale('color').range();
const categories = vegaView.scale('color').domain()
Upvotes: 0