Skip to main content
All docs
V25.1
  • DxPieChart<T>.LegendClick Event

    Fires when a user clicks a legend item.

    Namespace: DevExpress.Blazor

    Assembly: DevExpress.Blazor.v25.1.dll

    NuGet Package: DevExpress.Blazor

    Declaration

    [Parameter]
    public EventCallback<PieChartLegendClickEventArgs> LegendClick { get; set; }

    Event Data

    The LegendClick event's data class is PieChartLegendClickEventArgs. The following properties provide information specific to this event:

    Property Description
    Point Returns the data point associated with the clicked legend item.
    Series Returns the series associated with the clicked legend item.

    Remarks

    The DxPieChart component’s legend lists all pie sectors as legend items. When a user clicks an item, the component raises the LegendClick event. In a handler, you can use Series and Point argument properties to obtain information about the series and point associated with the clicked legend item.

    <DxChart Data="@DataSource"
             @ref="chart"
             Width="1200px"
             Height="300px"
             SeriesSelectionMode="ChartSelectionMode.Single"
             LegendClick="@OnChartLegendClick">
        <DxChartBarSeries ArgumentField="@((StatisticPoint v) => v.Country)"
                          ValueField="@((StatisticPoint v) => v.Population24)"
                          Name="2024"
                          HoverMode="ChartSeriesPointHoverMode.None" />
        <DxChartLineSeries ArgumentField="@((StatisticPoint v) => v.Country)"
                           ValueField="@((StatisticPoint v) => v.Population23)"
                           Name="2023"
                           HoverMode="ChartContinuousSeriesHoverMode.None" />
        <DxChartLegend HoverMode="ChartLegendHoverMode.None" />
    </DxChart>
    
    @code {
        DxChart<StatisticPoint> chart;
    
        public void OnChartLegendClick(ChartLegendClickEventArgs args) {
            if (args.Series != null) {
                var SeriesName = args.Series.Name;
                var TotalPopulation = SeriesName == "2023" ? DataSource.Select(x => x.Population23).Sum() : DataSource.Select(x => x.Population24).Sum();
                ShowDetailDialog(SeriesName, TotalPopulation);
            }
        }
        // ...
    }
    
    See Also