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 - Point Selection API

This demo shows how easily you can access a necessary chart series and select a specific point in it using the API.

Backend API
<dx-chart id="chart" [dataSource]="catBreedsData" [rotated]="true" title="Most Popular US Cat Breeds" (onDone)="done($event)" (onPointClick)="pointClick($event)" > <dxi-chart-series valueField="count" name="breeds" color="#a3d6d2"> <dxo-chart-selection-style color="#ec2e7a"> <dxo-chart-hatching direction="none"></dxo-chart-hatching> </dxo-chart-selection-style> </dxi-chart-series> <dxo-chart-common-series-settings argumentField="breed" type="bar"> </dxo-chart-common-series-settings> <dxo-chart-legend [visible]="false"></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, type DxChartTypes } from 'devextreme-angular/ui/chart'; import { Service, CatBreed } 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 { catBreedsData: CatBreed[]; constructor(service: Service) { this.catBreedsData = service.getCatBreedsData(); } done(e: DxChartTypes.DoneEvent) { e.component.getSeriesByPos(0).getPointsByArg('Siamese')[0].select(); } pointClick(e: DxChartTypes.PointClickEvent) { const point = e.target; 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 CatBreed { breed: string; count: number; } const catBreeds: CatBreed[] = [{ breed: 'Domestic Shorthair', count: 62942, }, { breed: 'American Shorthair', count: 38287, }, { breed: 'Domestic Medium Hair', count: 15652, }, { breed: 'Domestic Long Hair', count: 13670, }, { breed: 'Siamese', count: 13377, }, { breed: 'Maine Coon', count: 11254, }, { breed: 'Persian', count: 7198, }, { breed: 'Russian Blue', count: 3569, }, { breed: 'Himalayan', count: 3755, }, { breed: 'Ragdoll', count: 3426, }, { breed: 'Bengal', count: 2966, }, { breed: 'Manx', count: 2391, }, { breed: 'British Shorthair', count: 2329, }, { breed: 'Norwegian Forest Cat', count: 1817, }, { breed: 'Bombay', count: 1486, }]; @Injectable() export class Service { getCatBreedsData(): CatBreed[] { return catBreeds; } }
<!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>