Axis labels in Angular 3D Chart control

27 Apr 202418 minutes to read

Axis labels are the labels that are positioned adjacent to the y-axis and beneath the x-axis. It provides descriptive information about the axis.

Smart axis labels

When the axis labels overlap with each other, labelIntersectAction property in the axis can be used to place them smartly.

Case 1: When setting labelIntersectAction as Hide.

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' [primaryYAxis]="primaryYAxis"
    rotation=7 tilt=10 depth=100 [enableRotation]='enableRotation'>
    <e-chart3d-series-collection>
        <e-chart3d-series [dataSource]='dataSource' type='Column' xName='x' yName='y'>
        </e-chart3d-series>
    </e-chart3d-series-collection>
</ejs-chart3d>`
})
export class AppComponent {
    public dataSource?: Object[];
    public primaryXAxis?: Object;
    public enableRotation?: boolean;
    public primaryYAxis?: Object;
    ngOnInit(): void {
        this.dataSource = [
            { x: "South Korea", y: 39.4 },
            { x: "India", y: 61.3 },
            { x: "Pakistan", y: 20.4 },
            { x: "Germany", y: 65.1 },
            { x: "Australia", y: 15.8 },
            { x: "Italy", y: 29.2 },
            { x: "United Kingdom", y: 44.6 },
            { x: "Saudi Arabia", y: 9.7 },
            { x: "Russia", y: 40.8 },
            { x: "Mexico", y: 31 },
            { x: "Brazil", y: 75.9 },
            { x: "China", y: 51.4 }
        ];
        this.primaryXAxis = {
            valueType: "Category",
            labelIntersectAction: 'Hide'
        };
        this.enableRotation = true;
        this.primaryYAxis = {  };
    }
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));

Case 2: When setting labelIntersectAction as Rotate45.

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' [primaryYAxis]="primaryYAxis"
    rotation=7 tilt=10 depth=100 [enableRotation]='enableRotation'>
    <e-chart3d-series-collection>
        <e-chart3d-series [dataSource]='dataSource' type='Column' xName='x' yName='y'>
        </e-chart3d-series>
    </e-chart3d-series-collection>
</ejs-chart3d>`
})
export class AppComponent {
    public dataSource?: Object[];
    public primaryXAxis?: Object;
    public enableRotation?: boolean;
    public primaryYAxis?: Object;
    ngOnInit(): void {
        this.dataSource = [
            { x: "South Korea", y: 39.4 },
            { x: "India", y: 61.3 },
            { x: "Pakistan", y: 20.4 },
            { x: "Germany", y: 65.1 },
            { x: "Australia", y: 15.8 },
            { x: "Italy", y: 29.2 },
            { x: "United Kingdom", y: 44.6 },
            { x: "Saudi Arabia", y: 9.7 },
            { x: "Russia", y: 40.8 },
            { x: "Mexico", y: 31 },
            { x: "Brazil", y: 75.9 },
            { x: "China", y: 51.4 }
        ];
        this.primaryXAxis = {
            valueType: "Category",
            labelIntersectAction: 'Rotate45'
        };
        this.enableRotation = true;
        this.primaryYAxis = { };
    }
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));

Case 3: When setting labelIntersectAction as Rotate90.

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' [primaryYAxis]="primaryYAxis"
    rotation=7 tilt=10 depth=100 [enableRotation]='enableRotation'>
    <e-chart3d-series-collection>
        <e-chart3d-series [dataSource]='dataSource' type='Column' xName='x' yName='y'>
        </e-chart3d-series>
    </e-chart3d-series-collection>
</ejs-chart3d>`
})
export class AppComponent {
    public dataSource?: Object[];
    public primaryXAxis?: Object;
    public enableRotation?: boolean;
    public primaryYAxis?: Object;
    ngOnInit(): void {
        this.dataSource = [
            { x: "South Korea", y: 39.4 },
            { x: "India", y: 61.3 },
            { x: "Pakistan", y: 20.4 },
            { x: "Germany", y: 65.1 },
            { x: "Australia", y: 15.8 },
            { x: "Italy", y: 29.2 },
            { x: "United Kingdom", y: 44.6 },
            { x: "Saudi Arabia", y: 9.7 },
            { x: "Russia", y: 40.8 },
            { x: "Mexico", y: 31 },
            { x: "Brazil", y: 75.9 },
            { x: "China", y: 51.4 }
        ];
        this.primaryXAxis = {
            valueType: "Category",
            labelIntersectAction: 'Rotate90'
        };
        this.enableRotation = true;
        this.primaryYAxis = { };
    }
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));

Edge label placement

Labels with long text at the edges of an axis may appear partially in the 3D chart. To avoid this,
use the edgeLabelPlacement property in axis, which moves the label inside the chart area for better appearance or hides it.

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' [primaryYAxis]="primaryYAxis"
    rotation=7 tilt=10 depth=100 [enableRotation]='enableRotation'>
    <e-chart3d-series-collection>
        <e-chart3d-series [dataSource]='dataSource' type='Column' xName='x' yName='y'>
        </e-chart3d-series>
    </e-chart3d-series-collection>
</ejs-chart3d>`
})
export class AppComponent {
    public dataSource?: Object[];
    public primaryXAxis?: Object;
    public enableRotation?: boolean;
    public primaryYAxis?: Object;
    ngOnInit(): void {
        this.dataSource = [
            { x: "South Korea", y: 39.4 },
            { x: "India", y: 61.3 },
            { x: "Pakistan", y: 20.4 },
            { x: "Germany", y: 65.1 },
            { x: "Australia", y: 15.8 },
            { x: "Italy", y: 29.2 },
            { x: "United Kingdom", y: 44.6 },
            { x: "Saudi Arabia", y: 9.7 },
            { x: "Russia", y: 40.8 },
            { x: "Mexico", y: 31 },
            { x: "Brazil", y: 75.9 },
            { x: "China", y: 51.4 }
        ];
        this.primaryXAxis = {
            valueType: "Category",
            edgeLabelPlacement: 'Shift'
        };
        this.enableRotation = true;
        this.primaryYAxis = { };
    }
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));

Maximum labels

The labels will be rendered based on the count in the maximumLabels property per 100 pixel. If the range (minimum, maximum, interval) and maximumLabels are set, then the priority goes to range. If the range is not set, then the priority goes to maximumLabels 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' [primaryYAxis]="primaryYAxis"
    rotation=7 tilt=10 depth=100 [enableRotation]='enableRotation'>
    <e-chart3d-series-collection>
        <e-chart3d-series [dataSource]='dataSource' type='Column' xName='x' yName='y'>
        </e-chart3d-series>
    </e-chart3d-series-collection>
</ejs-chart3d>`
})
export class AppComponent {
    public dataSource?: Object[];
    public primaryXAxis?: Object;
    public enableRotation?: boolean;
    public primaryYAxis?: Object;
    ngOnInit(): void {
        let series1: Object[] = [];
        let point1: Object;
        let value: number = 80;
        let i: number;
        for (i = 1; i < 50; i++) {
            if (Math.random() > .5) {
                value += Math.random();
            } else {
                value -= Math.random();
            }
            point1 = { x: i, y: value.toFixed(1) };
            series1.push(point1);
        }
        this.dataSource = series1;
        this.primaryXAxis = {
            title: 'Years',
            edgeLabelPlacement: 'Shift',
            majorGridLines: { width: 0 },
            maximumLabels: 1,
        };
        this.enableRotation = true;
        this.primaryYAxis = { };
    }
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));