Tooltip in Angular 3D Chart control

18 Nov 201824 minutes to read

The 3D Chart will display details about the points through tooltip, when the mouse is moved over the specific point.

Default tooltip

By default, tooltip is not visible. The tooltip can be enabled by setting the enable property in tooltipSettings to true and by injecting Tooltip3DService module into the @NgModule.providers.

import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { Chart3DAllModule} from '@syncfusion/ej2-angular-charts'



import { Component } from '@angular/core';

@Component({
imports: [
         Chart3DAllModule
    ],


standalone: true,
    selector: 'app-container',
    // specifies the template string for the Chart component
    template: `<ejs-chart3d style='display:block;' align='center' [primaryXAxis]='primaryXAxis' [tooltip]="tooltip" 
    rotation=7 tilt=10 depth=100 [enableRotation]='enableRotation'>
    <e-chart3d-series-collection>
        <e-chart3d-series [dataSource]='dataSource' type='Column' xName='month' yName='sales'>
        </e-chart3d-series>
    </e-chart3d-series-collection>
</ejs-chart3d>`
})
export class AppComponent {
    public dataSource?: Object[];
    public primaryXAxis?: Object;
    public enableRotation?: boolean;
    public tooltip?: Object;
    ngOnInit(): void {
        this.dataSource = [
            { month: 'Jan', sales: 35 }, { month: 'Feb', sales: 28 },
            { month: 'Mar', sales: 34 }, { month: 'Apr', sales: 32 },
            { month: 'May', sales: 40 }, { month: 'Jun', sales: 32 },
            { month: 'Jul', sales: 35 }, { month: 'Aug', sales: 55 },
            { month: 'Sep', sales: 38 }, { month: 'Oct', sales: 30 },
            { month: 'Nov', sales: 25 }, { month: 'Dec', sales: 32 }
        ];
        this.primaryXAxis = {
            valueType: 'Category',
            labelRotation: -45,
            labelPlacement: 'BetweenTicks'
        };
        this.enableRotation = true;
        this.tooltip = { enable: true };
    }
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));

Fixed tooltip

By default, tooltip track the mouse movement, but the tooltip can be set in fixed position by using the location property.

import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { Chart3DAllModule} from '@syncfusion/ej2-angular-charts'



import { Component } from '@angular/core';

@Component({
imports: [
         Chart3DAllModule
    ],


standalone: true,
    selector: 'app-container',
    // specifies the template string for the Chart component
    template: `<ejs-chart3d style='display:block;' align='center' [primaryXAxis]='primaryXAxis' [tooltip]="tooltip" 
    rotation=7 tilt=10 depth=100 [enableRotation]='enableRotation'>
    <e-chart3d-series-collection>
        <e-chart3d-series [dataSource]='dataSource' type='Column' xName='month' yName='sales'>
        </e-chart3d-series>
    </e-chart3d-series-collection>
</ejs-chart3d>`
})
export class AppComponent {
    public dataSource?: Object[];
    public primaryXAxis?: Object;
    public enableRotation?: boolean;
    public tooltip?: Object;
    ngOnInit(): void {
        this.dataSource = [
            { month: 'Jan', sales: 35 }, { month: 'Feb', sales: 28 },
            { month: 'Mar', sales: 34 }, { month: 'Apr', sales: 32 },
            { month: 'May', sales: 40 }, { month: 'Jun', sales: 32 },
            { month: 'Jul', sales: 35 }, { month: 'Aug', sales: 55 },
            { month: 'Sep', sales: 38 }, { month: 'Oct', sales: 30 },
            { month: 'Nov', sales: 25 }, { month: 'Dec', sales: 32 }
        ];
        this.primaryXAxis = {
            valueType: 'Category',
            labelRotation: -45,
            labelPlacement: 'BetweenTicks'
        };
        this.enableRotation = true;
        this.tooltip = { 
            enable: true,
            location: {  x: 120, y: 20 }
        };
    }
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));

Format the tooltip

By default, tooltip shows information of x and y value in points. In addition to that, more information can be shown in tooltip by using the format property. For example the format ${series.name} : ${point.y} shows series name and point y value.

import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { Chart3DAllModule} from '@syncfusion/ej2-angular-charts'



import { Component } from '@angular/core';

@Component({
imports: [
         Chart3DAllModule
    ],


standalone: true,
    selector: 'app-container',
    // specifies the template string for the Chart component
    template: `<ejs-chart3d style='display:block;' align='center' [primaryXAxis]='primaryXAxis' [tooltip]="tooltip" 
    rotation=7 tilt=10 depth=100 [enableRotation]='enableRotation'>
    <e-chart3d-series-collection>
        <e-chart3d-series [dataSource]='dataSource' type='Column' xName='month' yName='sales' name="Month">
        </e-chart3d-series>
    </e-chart3d-series-collection>
</ejs-chart3d>`
})
export class AppComponent {
    public dataSource?: Object[];
    public primaryXAxis?: Object;
    public enableRotation?: boolean;
    public tooltip?: Object;
    ngOnInit(): void {
        this.dataSource = [
            { month: 'Jan', sales: 35 }, { month: 'Feb', sales: 28 },
            { month: 'Mar', sales: 34 }, { month: 'Apr', sales: 32 },
            { month: 'May', sales: 40 }, { month: 'Jun', sales: 32 },
            { month: 'Jul', sales: 35 }, { month: 'Aug', sales: 55 },
            { month: 'Sep', sales: 38 }, { month: 'Oct', sales: 30 },
            { month: 'Nov', sales: 25 }, { month: 'Dec', sales: 32 }
        ];
        this.primaryXAxis = {
            valueType: 'Category',
            labelRotation: -45,
            labelPlacement: 'BetweenTicks'
        };
        this.enableRotation = true;
        this.tooltip = { 
            enable: true,
            header: 'Unemployment',
            format: '<b>${series.name} : ${point.y}</b>'
        };
    }
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));

Inline tooltip formatting

The tooltip content can be formatted directly within the format property by adding DateTime or number format specifiers to supported tooltip tokens. This allows you to control how point and series values are displayed without using additional events.

A format specifier can be applied to a tooltip token by adding a colon (:) followed by the required format.

For example:

public tooltip = {
  enable: true,
  format: '${series.name} (${series.type})<br>${point.x:MMM yyyy} : ${point.y:n2}<br>Opacity: ${series.opacity}'
};

In the above example, point.x is displayed in month-year format, point.y is displayed with two decimal places, and series.opacity displays the opacity value applied to the series.

Inline formatting can be applied to the following tooltip tokens:

  • point.x – Specifies the x-value of the data point, such as DateTime or category values.
  • point.y – Specifies the numeric y-value of the data point.
  • series.name – Specifies the name assigned to the series.
  • series.type – Specifies the rendering type of the series, such as Column, Bar, Line, or StackingColumn.
  • series.opacity – Specifies the opacity value applied to the series. This value controls the visual transparency of the series and can be customized in the series configuration.

Important: The availability of point-specific tokens depends on the values configured in the data source and the 3D chart series type. The series.name and series.type tokens return string values, so DateTime or number formatting is not applied to these tokens.

The following format types are supported:

  • DateTime formats such as MMM yyyy, MM:yy, and dd MMM
  • Number formats such as:
    • n2 – number with two decimal places
    • n0 – number without decimal places
    • c2 – currency format
    • p1 – percentage format
    • e1 – exponential notation

If the specified format does not match the resolved value type, the original value is displayed.

import { Chart3DAllModule} from '@syncfusion/ej2-angular-charts'
import { Component } from '@angular/core';

@Component({
imports: [ Chart3DAllModule ],
standalone: true,
    selector: 'app-container',
    // specifies the template string for the Chart component
    template: `<ejs-chart3d id="chart3d" align='center' [primaryXAxis]="primaryXAxis" [tooltip]="tooltip" 
    [rotation]="rotation" [tilt]="tilt" [depth]="depth" [enableRotation]='enableRotation' [wallColor]="wallColor">
        <e-chart3d-series-collection>
            <e-chart3d-series [dataSource]="chartData" xName="month" yName="sales" type="Column" name="Month"></e-chart3d-series>
        </e-chart3d-series-collection>
</ejs-chart3d>`
})

export class AppComponent {

  public chartData: Object[] = [
    { month: new Date(2024, 0, 1), sales: 35 },
    { month: new Date(2024, 1, 1), sales: 28 },
    { month: new Date(2024, 2, 1), sales: 34 },
    { month: new Date(2024, 3, 1), sales: 32 },
    { month: new Date(2024, 4, 1), sales: 40 },
    { month: new Date(2024, 5, 1), sales: 32 },
    { month: new Date(2024, 6, 1), sales: 35 },
    { month: new Date(2024, 7, 1), sales: 55 },
    { month: new Date(2024, 8, 1), sales: 38 },
    { month: new Date(2024, 9, 1), sales: 30 },
    { month: new Date(2024, 10, 1), sales: 25 },
    { month: new Date(2024, 11, 1), sales: 32 }
  ];

  public tooltip = {
    enable: true,
    header: 'Unemployment',
    format: '<b>${series.name}</b><br>${point.x:MMM yyyy} : ${point.y:n2}'
  };

  public primaryXAxis = {
    valueType: 'DateTime',
    labelRotation: -45,
    labelPlacement: 'BetweenTicks'
  };

  public series = [
    {
      dataSource: this.chartData,
      xName: 'month',
      yName: 'sales',
      type: 'Column',
      name: 'Month'
    }
  ];

  public rotation: number = 7;
  public tilt: number = 10;
  public depth: number = 100;
  public enableRotation: boolean = true;
  public wallColor: string = 'transparent';
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));

Tooltip template

Any HTML elements can be displayed in the tooltip by using the template property of the tooltip. The ${x} and ${y} can be used as place holders in the HTML element to display the x and y values of the corresponding data point.

import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { Chart3DAllModule} from '@syncfusion/ej2-angular-charts'



import { Component } from '@angular/core';

@Component({
imports: [
         Chart3DAllModule
    ],


standalone: true,
    selector: 'app-container',
    // specifies the template string for the Chart component
    template: `<ejs-chart3d style='display:block;' align='center' [primaryXAxis]='primaryXAxis' [tooltip]="tooltip" 
    rotation=7 tilt=10 depth=100 [enableRotation]='enableRotation'>
    <e-chart3d-series-collection>
        <e-chart3d-series [dataSource]='dataSource' type='Column' xName='month' yName='sales' name="Month">
        </e-chart3d-series>
    </e-chart3d-series-collection>
</ejs-chart3d>`
})
export class AppComponent {
    public dataSource?: Object[];
    public primaryXAxis?: Object;
    public enableRotation?: boolean;
    public tooltip?: Object;
    ngOnInit(): void {
        this.dataSource = [
            { month: 'Jan', sales: 35 }, { month: 'Feb', sales: 28 },
            { month: 'Mar', sales: 34 }, { month: 'Apr', sales: 32 },
            { month: 'May', sales: 40 }, { month: 'Jun', sales: 32 },
            { month: 'Jul', sales: 35 }, { month: 'Aug', sales: 55 },
            { month: 'Sep', sales: 38 }, { month: 'Oct', sales: 30 },
            { month: 'Nov', sales: 25 }, { month: 'Dec', sales: 32 }
        ];
        this.primaryXAxis = {
            valueType: 'Category',
            labelRotation: -45,
            labelPlacement: 'BetweenTicks'
        };
        this.enableRotation = true;
        this.tooltip = { 
            enable: true,
            template: '<div id="templateWrap"><table style="width:100%;  border: 1px solid black;"><tr><th colspan="2" bgcolor="#00FFFF">Unemployment</th></tr><tr><td bgcolor="#00FFFF">${x}:</td><td bgcolor="#00FFFF">${y}</td></tr></table></div>'
        };
    }
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));

Customize the appearance of tooltip

The fill and border properties are used to customize the background color and border of the tooltip respectively. The textStyle property in the tooltip is used to customize the font of the tooltip text.

import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { Chart3DAllModule} from '@syncfusion/ej2-angular-charts'



import { Component } from '@angular/core';

@Component({
imports: [
         Chart3DAllModule
    ],


standalone: true,
    selector: 'app-container',
    // specifies the template string for the Chart component
    template: `<ejs-chart3d style='display:block;' align='center' [primaryXAxis]='primaryXAxis' [tooltip]="tooltip" 
    rotation=7 tilt=10 depth=100 [enableRotation]='enableRotation'>
    <e-chart3d-series-collection>
        <e-chart3d-series [dataSource]='dataSource' type='Column' xName='month' yName='sales' name="Month">
        </e-chart3d-series>
    </e-chart3d-series-collection>
</ejs-chart3d>`
})
export class AppComponent {
    public dataSource?: Object[];
    public primaryXAxis?: Object;
    public enableRotation?: boolean;
    public tooltip?: Object;
    ngOnInit(): void {
        this.dataSource = [
            { month: 'Jan', sales: 35 }, { month: 'Feb', sales: 28 },
            { month: 'Mar', sales: 34 }, { month: 'Apr', sales: 32 },
            { month: 'May', sales: 40 }, { month: 'Jun', sales: 32 },
            { month: 'Jul', sales: 35 }, { month: 'Aug', sales: 55 },
            { month: 'Sep', sales: 38 }, { month: 'Oct', sales: 30 },
            { month: 'Nov', sales: 25 }, { month: 'Dec', sales: 32 }
        ];
        this.primaryXAxis = {
            valueType: 'Category',
            labelRotation: -45,
            labelPlacement: 'BetweenTicks'
        };
        this.enableRotation = true;
        this.tooltip = {
            enable: true,
            format: '${series.name} ${point.x} : ${point.y}',
            fill: '#7bb4eb',
            border: {
                width: 2,
                color: 'grey'
            }
        };
    }
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));