Your search did not match any results.
Sparkline Charts

Bar Sparklines


This demo illustrates the sparklines of the bar type. A number of properties for each sparkline is changed. Most of these properties define the appearance of specific sparkline elements. Note that in this demo, the Sparkline component obtains data using the DataSource object. You can change filtering conditions for the data using the drop-down menu under the table.

Copy to CodeSandBox
<div class="long-title"><h3>Monthly Prices of Aluminium, Nickel and Copper</h3></div> <div id="chart-demo"> <table class="demo-table" border="1"> <tr> <th></th> <th>Aluminium (USD/ton)</th> <th>Nickel (USD/ton)</th> <th>Copper (USD/ton)</th> </tr> <tr *ngFor="let year of years"> <th>{{year}}</th> <td> <dx-sparkline class="sparkline" [dataSource]="source" argumentField="month" valueField="alum{{year}}" type="bar" [showMinMax]="true"> <dxo-tooltip format="currency"></dxo-tooltip> </dx-sparkline> </td> <td> <dx-sparkline class="sparkline" [dataSource]="source" argumentField="month" valueField="nickel{{year}}" type="bar" [showMinMax]="true" [showFirstLast]="false" barPositiveColor="#6babac" minColor="#9ab57e" maxColor="#8076bb"> <dxo-tooltip format="currency"></dxo-tooltip> </dx-sparkline> </td> <td> <dx-sparkline class="sparkline" [dataSource]="source" argumentField="month" valueField="copper{{year}}" type="bar" barPositiveColor="#e55253" firstLastColor="#ebdd8f"> <dxo-tooltip format="currency"></dxo-tooltip> </dx-sparkline> </td> </tr> </table> <div class="action"> <dx-select-box id="choose-months" [dataSource]="filters" [width]="70" [value]="filters[0]" (onValueChanged)="onValueChanged($event)"> </dx-select-box> <div class="label">Choose a number of months: </div> </div> </div>
import { NgModule, Component, enableProdMode } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { HttpClient, HttpClientModule } from '@angular/common/http'; import { DxSparklineModule, DxSelectBoxModule } from 'devextreme-angular'; import DataSource from 'devextreme/data/data_source'; import CustomStore from 'devextreme/data/custom_store'; import query from 'devextreme/data/query'; if(!/localhost/.test( { enableProdMode(); } @Component({ selector: 'demo-app', templateUrl: 'app/app.component.html', styleUrls: ['app/app.component.css'] }) export class AppComponent { source: any; filters: number[] = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]; years: Array<number>; constructor(http: HttpClient) { this.source = new DataSource({ store: new CustomStore({ load: () => http.get('../../../../data/resourceData.json') .toPromise() .catch(error => { throw 'Data Loading Error' }), loadMode: 'raw' }), filter: ["month", "<=", "12"], paginate: false }); this.years = [2010, 2011, 2012]; } onValueChanged(e) { let count = e.value; this.source.filter(["month", "<=", count]); this.source.load(); } } @NgModule({ imports: [ BrowserModule, HttpClientModule, DxSparklineModule, DxSelectBoxModule ], declarations: [AppComponent], bootstrap: [AppComponent] }) export class AppModule { } platformBrowserDynamic().bootstrapModule(AppModule);
::ng-deep #chart-demo { height: 440px; } ::ng-deep .demo-table { width: 100%; border: 1px solid #c2c2c2; border-collapse: collapse; } ::ng-deep .demo-table th, ::ng-deep .demo-table td { font-weight: 400; width: 200px; padding: 25px 10px 5px 10px; border: 1px solid #c2c2c2; } ::ng-deep .demo-table th { padding: 25px 15px 20px 15px; border: 1px solid #c2c2c2; } ::ng-deep .demo-table tr:nth-child(2) td { border-top: 1px solid #c2c2c2; } ::ng-deep .demo-table td:first-of-type { border-left: 1px solid #c2c2c2; } ::ng-deep .demo-table .sparkline { width: 200px; height: 30px; } ::ng-deep #choose-months { float: right; } ::ng-deep .action { width: 270px; margin-top: 20px; } ::ng-deep .label { padding-top: 9px; } ::ng-deep .long-title h3 { font-weight: 200; font-size: 28px; text-align: center; margin-bottom: 20px; }
// In real applications, you should not transpile code in the browser. You can see how to create your own application with Angular and DevExtreme here: // System.config({ transpiler: 'ts', typescriptOptions: { module: "system", emitDecoratorMetadata: true, experimentalDecorators: true }, meta: { 'typescript': { "exports": "ts" }, 'devextreme/localization.js': { "esModule": true } }, paths: { 'npm:': '' }, map: { 'ts': 'npm:plugin-typescript@8.0.0/lib/plugin.js', 'typescript': 'npm:typescript@3.5.3/lib/typescript.js', '@angular': 'npm:@angular', 'tslib': 'npm:tslib@2.2.0/tslib.js', 'rxjs': 'npm:rxjs@6.4.0', 'rrule': 'npm:rrule@2.6.6/dist/es5/rrule.js', 'luxon': 'npm:luxon@1.26.0/build/global/luxon.min.js', 'es6-object-assign': 'npm:es6-object-assign@1.1.0', 'devextreme': 'npm:devextreme@20.2.7', 'jszip': 'npm:jszip@3.6.0/dist/jszip.min.js', 'devextreme-quill': 'npm:devextreme-quill@0.10.3/dist/dx-quill.min.js', 'devexpress-diagram': 'npm:devexpress-diagram@2.0.23', 'devexpress-gantt': 'npm:devexpress-gantt@2.0.29', 'devextreme-angular': 'npm:devextreme-angular@20.2.6', 'preact': 'npm:preact@10.5.13/dist/preact.js', 'preact/hooks': 'npm:preact@10.5.13/hooks/dist/hooks.js' }, packages: { 'app': { main: './app.component.ts', defaultExtension: 'ts' }, 'devextreme': { defaultExtension: 'js' }, 'devextreme/events/utils': { main: 'index' }, 'devextreme/events': { main: 'index' }, 'es6-object-assign': { main: './index.js', defaultExtension: 'js' } }, packageConfigPaths: [ "npm:@angular/*/package.json", "npm:@angular/common/*/package.json", "npm:rxjs/package.json", "npm:rxjs/operators/package.json", "npm:devextreme-angular/*/package.json", "npm:devextreme-angular/ui/*/package.json", "npm:devextreme-angular/package.json", "npm:devexpress-diagram/package.json", "npm:devexpress-gantt/package.json", ] });
<!DOCTYPE html> <html xmlns=""> <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=1.0" /> <link rel="stylesheet" type="text/css" href="" /> <link rel="stylesheet" type="text/css" href="" /> <script src=""></script> <script src=""></script> <script src=""></script> <script src=""></script> <script src="config.js"></script> <script> System.import('app').catch(console.error.bind(console)); </script> </head> <body class="dx-viewport"> <div class="demo-container"> <demo-app>Loading...</demo-app> </div> </body> </html>