Your search did not match any results.
Charts

Tooltip HTML Support

Documentation
In this demo, tooltips are displayed using an HTML template defined in the tooltip | customizeTooltip function.
en.wikipedia.org
Copy to Plunker
Apply
Reset
<dx-pie-chart id="pie-chart" [dataSource]="populationData" palette="bright" title="Top 10 Most Populated States in US"> <dxi-series argumentField="name" valueField="population" tagField="data"> </dxi-series> <dxo-tooltip [enabled]="true" [customizeTooltip]="customizeTooltip"> </dxo-tooltip> <dxo-export [enabled]="true"></dxo-export> </dx-pie-chart>
import { NgModule, Component, enableProdMode } from '@angular/core'; import { DecimalPipe } from '@angular/common'; import { BrowserModule } from '@angular/platform-browser'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { DxPieChartModule } from 'devextreme-angular'; import { Service, State } from './app.service'; if(!/localhost/.test(document.location.host)) { enableProdMode(); } @Component({ selector: 'demo-app', providers: [Service], templateUrl: 'app/app.component.html', styleUrls: ['app/app.component.css'] }) export class AppComponent { populationData: State[]; pipe: any = new DecimalPipe(); constructor(service: Service) { this.populationData = service.getPopulationData(); } customizeTooltip = (args: any) => { return { html: "<div class='state-tooltip'><img src='../../../../images/flags/" + args.point.tag.flag + ".gif' /><h4>" + args.argument + "</h4><div><b>Capital</b>: " + args.point.tag.capital + "</div><div><b>Population</b>: " + this.pipe.transform(args.value, "3.0-0") + " people</div>" + "<div><b>Area</b>: " + this.pipe.transform(args.point.tag.area, "3.0-0") + " km<sup>2</sup> (" + this.pipe.transform(0.3861 * args.point.tag.area, "3.0-0") + " mi<sup>2</sup>)" + "</div>" + "</div>" }; } } @NgModule({ imports: [ BrowserModule, DxPieChartModule ], declarations: [AppComponent], bootstrap: [AppComponent] }) export class AppModule { } platformBrowserDynamic().bootstrapModule(AppModule);
/deep/ #pie-chart { height: 440px; } /deep/ .state-tooltip { height: 90px; } /deep/ .state-tooltip > img { width: 60px; height: 40px; display: block; margin: 0 5px 0 0; float: left; } /deep/ .state-tooltip > h4 { line-height: 40px; font-size: 14px; margin-bottom: 5px; } /deep/ .state-tooltip sup { font-size: 0.8em; vertical-align: super; line-height: 0; }
import { Injectable } from '@angular/core'; export interface CapitalInfo { capital: string; area: number; flag: string; } export interface State { name: string; population: number; data: CapitalInfo } let populationData: State[] = [{ name: "California", population: 38802500, data: { capital: "Sacramento", area: 423967, flag: "california" } }, { name: "Texas", area: 695662, population: 26956958, data: { capital: "Austin", area: 423967, flag: "texas" } }, { name: "Florida", area: 170312, population: 19893297, data: { capital: "Tallahassee", area: 423967, flag: "florida" } }, { name: "New York", area: 141297, population: 19746227, data: { capital: "Albany", area: 423967, flag: "newyork" } }, { name: "Illinois", area: 149995, population: 12880580, data: { capital: "Springfield", area: 423967, flag: "illinois" } }, { name: "Pennsylvania", area: 119280, population: 12787209, data: { capital: "Harrisburg", area: 423967, flag: "pennsylvania" } }, { name: "Ohio", area: 116098, population: 11594163, data: { capital: "Columbus", area: 423967, flag: "ohio" } }, { name: "Georgia", area: 153910, population: 10097343, data: { capital: "Atlanta", area: 423967, flag: "georgia" } }, { name: "North Carolina", area: 139391, population: 9943964, data: { capital: "Raleigh", area: 423967, flag: "northcarolina" } }, { name: "Michigan", area: 250487, population: 9909877, data: { capital: "Lansing", area: 423967, flag: "michigan" } }]; @Injectable() export class Service { getPopulationData(): Population[] { return populationData; } }
// In real applications, you should not transpile code in the browser. You can see how to create your own application with Angular 2 and DevExtreme here: // https://github.com/DevExpress/devextreme-angular/blob/master/README.md System.config({ transpiler: 'ts', typescriptOptions: { module: "commonjs", emitDecoratorMetadata: true, experimentalDecorators: true }, meta: { 'typescript': { "exports": "ts" } }, paths: { 'npm:': 'https://unpkg.com/' }, map: { 'ts': 'npm:plugin-typescript@7.0.6/lib/plugin.js', 'typescript': 'npm:typescript@2.2.2/lib/typescript.js', '@angular/core': 'npm:@angular/core@4.1.0/bundles/core.umd.js', '@angular/common': 'npm:@angular/common@4.1.0/bundles/common.umd.js', '@angular/compiler': 'npm:@angular/compiler@4.1.0/bundles/compiler.umd.js', '@angular/platform-browser': 'npm:@angular/platform-browser@4.1.0/bundles/platform-browser.umd.js', '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic@4.1.0/bundles/platform-browser-dynamic.umd.js', '@angular/http': 'npm:@angular/http@4.1.0/bundles/http.umd.js', '@angular/router': 'npm:@angular/router@4.1.0/bundles/router.umd.js', '@angular/forms': 'npm:@angular/forms@4.1.0/bundles/forms.umd.js', 'rxjs': 'npm:rxjs@5.3.1', 'jszip': 'npm:jszip@3.1.3/dist/jszip.min.js', 'devextreme': 'npm:devextreme@17.1', 'jquery': 'npm:jquery@3.1.1/dist/jquery.min.js', 'devextreme-angular': 'npm:devextreme-angular@17.1' }, packages: { 'app': { main: './app.component.ts', defaultExtension: 'ts' }, 'devextreme': { defaultExtension: 'js' }, 'devextreme-angular': { main: 'index.js', defaultExtension: 'js' } } });
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <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="https://cdn3.devexpress.com/jslib/17.1.5/css/dx.spa.css" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/17.1.5/css/dx.common.css" /> <link rel="dx-theme" data-theme="generic.light" href="https://cdn3.devexpress.com/jslib/17.1.5/css/dx.light.css" /> <script src="https://unpkg.com/core-js@2.4.1/client/shim.min.js"></script> <script src="https://unpkg.com/zone.js@0.6.25/dist/zone.js"></script> <script src="https://unpkg.com/reflect-metadata@0.1.3/Reflect.js"></script> <script src="https://unpkg.com/systemjs@0.19.31/dist/system.js"></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>