@namespace Connected.Components
@inherits Chart

@if (ChartParent?.ChartOptions.DisableLegend != true)
{
    <div @attributes="CustomAttributes" class="chart-legend">
        @foreach (var item in Data)
        {
            <div class="chart-legend-item" @onclick=@(()=>{ if (ChartParent!=null) { ChartParent.SelectedIndex=item.Index; }}) @onclick:stopPropagation=@(ChartParent!=null)>
                <span class="chart-legend-marker" style="@($"background-color:{ChartParent.ChartOptions.ChartPalette.GetValue(item.Index % ChartOptions.ChartPalette.Count())}")"></span>
                <TextContent Typo="Typo.body2" Inline="true">@item.Labels</TextContent>
            </div>
        }
    </div>
}
