DevExtreme v26.1 is now available.

Explore our newest features/capabilities and share your thoughts with us.

Your search did not match any results.

Angular Charts - Multiple Point Selection

This demo illustrates the use of multi-point selection within the Chart component.

www.wikipedia.org
Backend API
<dx-chart id="chart" [dataSource]="medalsInfo" pointSelectionMode="multiple" [rotated]="true" title="Olympic Medals in 2024" (onPointClick)="pointClick($event)" > <dxi-chart-series valueField="gold" name="Gold Medals" color="#ffd700" ></dxi-chart-series> <dxi-chart-series valueField="silver" name="Silver Medals" color="#c0c0c0" ></dxi-chart-series> <dxi-chart-series valueField="bronze" name="Bronze Medals" color="#cd7f32" ></dxi-chart-series> <dxo-chart-common-series-settings argumentField="country" type="stackedbar"> <dxo-chart-selection-style> <dxo-chart-hatching direction="left"></dxo-chart-hatching> </dxo-chart-selection-style> </dxo-chart-common-series-settings> <dxo-chart-legend verticalAlignment="bottom" horizontalAlignment="center"> </dxo-chart-legend> <dxo-chart-export [enabled]="true"></dxo-chart-export> </dx-chart>
import { bootstrapApplication } from '@angular/platform-browser'; import { Component, enableProdMode, provideZoneChangeDetection } from '@angular/core'; import { DxChartModule, DxChartTypes } from 'devextreme-angular/ui/chart'; import { Service, MedalsInfo } from './app.service'; if (!/localhost/.test(document.location.host)) { enableProdMode(); } @Component({ selector: 'demo-app', providers: [Service], templateUrl: './app.component.html', styleUrls: ['./app.component.css'], imports: [ DxChartModule, ], }) export class AppComponent { medalsInfo: MedalsInfo[]; constructor(service: Service) { this.medalsInfo = service.getMedalsInfo(); } pointClick({ target: point }: DxChartTypes.PointClickEvent) { if (point.isSelected()) { point.clearSelection(); } else { point.select(); } } } bootstrapApplication(AppComponent, { providers: [ provideZoneChangeDetection({ eventCoalescing: true, runCoalescing: true }), ], });
::ng-deep #chart { height: 440px; }
import { Injectable } from '@angular/core'; export class MedalsInfo { country: string; gold: number; silver: number; bronze: number; } const medalsInfo: MedalsInfo[] = [{ country: 'USA', gold: 40, silver: 44, bronze: 42, }, { country: 'Japan', gold: 20, silver: 12, bronze: 13, }, { country: 'Australia', gold: 18, silver: 19, bronze: 16, }, { country: 'France', gold: 16, silver: 26, bronze: 22, }, { country: 'Great Britain', gold: 14, silver: 22, bronze: 29, }, { country: 'Italy', gold: 12, silver: 13, bronze: 15, }]; @Injectable() export class Service { getMedalsInfo(): MedalsInfo[] { return medalsInfo; } }
<!DOCTYPE html> <html lang="en"> <head> <title>DevExtreme Demo</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/26.1.5/css/dx.light.css" /> </head> <body class="dx-viewport"> <div class="demo-container"> <demo-app>Loading...</demo-app> </div> <script src="https://cdn.jsdelivr.net/npm/zone.js@0.16.2/bundles/zone.umd.js"></script> <script src="./bundle.js" type="module"></script> </body> </html>