User Interaction

A user can interact with the legend by pausing on legend items. When a user does this, the series that corresponds to the legend item being paused on becomes highlighted. To disable this capability, set the hoverMode option to "none".

jQuery
JavaScript
$(function() {
    $("#chartContainer").dxChart({
        // ...
        legend: {
            hoverMode: "none"
        }
    });
});
Angular
HTML
<dx-chart>
    <dxo-legend hoverMode="none"></dxo-legend>
</dx-chart>

Series that consist of several elements rather than just series points (Range Area, all line and area series) can be highlighted without the series points. For this, set the hoverMode option to "excludePoints". For other series, this setting has the same effect as "none".

jQuery
JavaScript
$(function() {
    $("#chartContainer").dxChart({
        // ...
        legend: {
            hoverMode: "excludePoints"
        }
    });
});
Angular
HTML
<dx-chart>
    <dxo-legend hoverMode="excludePoints"></dxo-legend>
</dx-chart>

Pausing on a legend item causes the seriesHoverChanged event to raise. Refer to the Series Hover Events topic for details on handling this event.

View Demo

In addition, a user can click legend items. By default, the widget does not react to a click, but you can instruct it to by handling the legendClick event. If the handling function is not going to be changed at runtime, assign it to the onLegendClick option when you configure the widget. Otherwise, or if you need several handlers for the legendClick event, subscribe to it using the on(eventName, eventHandler) method. This approach is more typical of jQuery.

jQuery
JavaScript
$(function() {
    $("#chartContainer").dxChart({
        // ...
        onLegendClick: function (e) {
            var series = e.target;
            // Event handling commands go here
        }
    });

    // ===== or =====
    var legendClickEventHandler1 = function (e) {
        var series = e.target;
        // First handler of the "legendClick" event
    };

    var legendClickEventHandler2 = function (e) {
        var series = e.target;
        // Second handler of the "legendClick" event
    };

    $("#chartContainer").dxChart("instance")
        .on("legendClick", legendClickEventHandler1)
        .on("legendClick", legendClickEventHandler2);
});
Angular
HTML
TypeScript
<dx-chart
    (onLegendClick)="onLegendClick($event)">
</dx-chart>
export class AppComponent {
    onLegendClick (e) {
        let series = e.target;
        // Event handling commands go here
    }
}
See Also