DevExtreme Vue - 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
$(function() { $("#chartContainer").dxChart({ // ... legend: { hoverMode: "none" } }); });
Angular
<dx-chart> <dxo-legend hoverMode="none"></dxo-legend> </dx-chart>
import { DxChartModule } from "devextreme-angular"; // ... export class AppComponent { // ... } @NgModule({ imports: [ // ... DxChartModule ], // ... })
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
$(function() { $("#chartContainer").dxChart({ // ... legend: { hoverMode: "excludePoints" } }); });
Angular
<dx-chart> <dxo-legend hoverMode="excludePoints"></dxo-legend> </dx-chart>
import { DxChartModule } from "devextreme-angular"; // ... export class AppComponent { // ... } @NgModule({ imports: [ // ... DxChartModule ], // ... })
Pausing on a legend item causes the seriesHoverChanged event to raise. Refer to the Series Hover Events topic for details on handling this event.
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
$(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
<dx-chart (onLegendClick)="onLegendClick($event)"> </dx-chart>
import { DxChartModule } from "devextreme-angular"; // ... export class AppComponent { onLegendClick (e) { let series = e.target; // Event handling commands go here } } @NgModule({ imports: [ // ... DxChartModule ], // ... })
See Also
- Handle Events: Angular | Vue | React | jQuery | AngularJS | Knockout | ASP.NET MVC 5 | ASP.NET Core
- Relocate the Legend
- Rearrange Legend Items
- Chart Demos
- Chart API Reference
If you have technical questions, please create a support ticket in the DevExpress Support Center.