add
Adds a legend to the container.
Implementation Details:
Increments a reference count for the legend ID.
If it's a new ID, it determines the initial unit system (Metric vs Imperial) by inspecting the BarLegend items or falling back to the global control unit.
Injects a LegendView and manages vertical separators.
Parameters
legend
The legend data to be visualized.