Selection in Angular 3D Chart control
12 Jan 202424 minutes to read
The 3D chart provides selection support for the series and its data points on mouse click.
When mouse is clicked on the data points, the corresponding series legend will also be selected.
We have different types of selection mode for selecting a data.
- None
- Point
- Series
- Cluster
Point
To select a point, set the selectionMode
property to Point.
import { Component } from '@angular/core';
@Component({
selector: 'app-container',
// specifies the template string for the Chart component
template: `<ejs-chart3d style='display:block;' align='center' [primaryXAxis]='primaryXAxis' [selectionMode]="selection"
rotation=7 tilt=10 depth=100 [enableRotation]='enableRotation'>
<e-chart3d-series-collection>
<e-chart3d-series [dataSource]='dataSource' type='Column' xName='country' yName='gold'>
</e-chart3d-series>
<e-chart3d-series [dataSource]='dataSource' type='Column' xName='country' yName='silver'>
</e-chart3d-series>
<e-chart3d-series [dataSource]='dataSource' type='Column' xName='country' yName='bronze'>
</e-chart3d-series>
</e-chart3d-series-collection>
</ejs-chart3d>`
})
export class AppComponent {
public dataSource?: Object[];
public primaryXAxis?: Object;
public selection?: String;
public enableRotation?: boolean;
ngOnInit(): void {
this.dataSource = [
{ country: "USA", gold: 50, silver: 70, bronze: 45 },
{ country: "China", gold: 40, silver: 60, bronze: 55 },
{ country: "Japan", gold: 70, silver: 60, bronze: 50 },
{ country: "Australia", gold: 60, silver: 56, bronze: 40 },
{ country: "France", gold: 50, silver: 45, bronze: 35 },
{ country: "Germany", gold: 40, silver: 30, bronze: 22 },
{ country: "Italy", gold: 40, silver: 35, bronze: 37 },
{ country: "Sweden", gold: 30, silver: 25, bronze: 27 }
];
this.primaryXAxis = {
valueType: 'Category',
labelRotation: -45,
labelPlacement: 'BetweenTicks'
};
this.enableRotation = true;
this.selection = "Point";
}
}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { Chart3DAllModule} from '@syncfusion/ej2-angular-charts';
/**
* Module
*/
@NgModule({
imports: [
BrowserModule, Chart3DAllModule
],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule { }
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';
import 'zone.js';
enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);
Series
To select a series, set the selectionMode
property to Series.
import { Component } from '@angular/core';
@Component({
selector: 'app-container',
// specifies the template string for the Chart component
template: `<ejs-chart3d style='display:block;' align='center' [primaryXAxis]='primaryXAxis' [selectionMode]="selection"
rotation=7 tilt=10 depth=100 [enableRotation]='enableRotation'>
<e-chart3d-series-collection>
<e-chart3d-series [dataSource]='dataSource' type='Column' xName='country' yName='gold'>
</e-chart3d-series>
<e-chart3d-series [dataSource]='dataSource' type='Column' xName='country' yName='silver'>
</e-chart3d-series>
<e-chart3d-series [dataSource]='dataSource' type='Column' xName='country' yName='bronze'>
</e-chart3d-series>
</e-chart3d-series-collection>
</ejs-chart3d>`
})
export class AppComponent {
public dataSource?: Object[];
public primaryXAxis?: Object;
public selection?: String;
public enableRotation?: boolean;
ngOnInit(): void {
this.dataSource = [
{ country: "USA", gold: 50, silver: 70, bronze: 45 },
{ country: "China", gold: 40, silver: 60, bronze: 55 },
{ country: "Japan", gold: 70, silver: 60, bronze: 50 },
{ country: "Australia", gold: 60, silver: 56, bronze: 40 },
{ country: "France", gold: 50, silver: 45, bronze: 35 },
{ country: "Germany", gold: 40, silver: 30, bronze: 22 },
{ country: "Italy", gold: 40, silver: 35, bronze: 37 },
{ country: "Sweden", gold: 30, silver: 25, bronze: 27 }
];
this.primaryXAxis = {
valueType: 'Category',
labelRotation: -45,
labelPlacement: 'BetweenTicks'
};
this.enableRotation = true;
this.selection = "Series";
}
}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { Chart3DAllModule} from '@syncfusion/ej2-angular-charts';
/**
* Module
*/
@NgModule({
imports: [
BrowserModule, Chart3DAllModule
],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule { }
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';
import 'zone.js';
enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);
Cluster
To select the points that corresponds to the same index in all the series, set the selectionMode
property to Cluster.
import { Component } from '@angular/core';
@Component({
selector: 'app-container',
// specifies the template string for the Chart component
template: `<ejs-chart3d style='display:block;' align='center' [primaryXAxis]='primaryXAxis' [selectionMode]="selection"
rotation=7 tilt=10 depth=100 [enableRotation]='enableRotation'>
<e-chart3d-series-collection>
<e-chart3d-series [dataSource]='dataSource' type='Column' xName='country' yName='gold'>
</e-chart3d-series>
<e-chart3d-series [dataSource]='dataSource' type='Column' xName='country' yName='silver'>
</e-chart3d-series>
<e-chart3d-series [dataSource]='dataSource' type='Column' xName='country' yName='bronze'>
</e-chart3d-series>
</e-chart3d-series-collection>
</ejs-chart3d>`
})
export class AppComponent {
public dataSource?: Object[];
public primaryXAxis?: Object;
public selection?: String;
public enableRotation?: boolean;
ngOnInit(): void {
this.dataSource = [
{ country: "USA", gold: 50, silver: 70, bronze: 45 },
{ country: "China", gold: 40, silver: 60, bronze: 55 },
{ country: "Japan", gold: 70, silver: 60, bronze: 50 },
{ country: "Australia", gold: 60, silver: 56, bronze: 40 },
{ country: "France", gold: 50, silver: 45, bronze: 35 },
{ country: "Germany", gold: 40, silver: 30, bronze: 22 },
{ country: "Italy", gold: 40, silver: 35, bronze: 37 },
{ country: "Sweden", gold: 30, silver: 25, bronze: 27 }
];
this.primaryXAxis = {
valueType: 'Category',
labelRotation: -45,
labelPlacement: 'BetweenTicks'
};
this.enableRotation = true;
this.selection = "Cluster";
}
}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { Chart3DAllModule} from '@syncfusion/ej2-angular-charts';
/**
* Module
*/
@NgModule({
imports: [
BrowserModule, Chart3DAllModule
],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule { }
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';
import 'zone.js';
enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);
Selection type
To select multiple points or series, enable the isMultiSelect
property.
import { Component } from '@angular/core';
@Component({
selector: 'app-container',
// specifies the template string for the Chart component
template: `<ejs-chart3d style='display:block;' align='center' [primaryXAxis]='primaryXAxis' [selectionMode]="selection" [isMultiSelect]=true
rotation=7 tilt=10 depth=100 [enableRotation]='enableRotation'>
<e-chart3d-series-collection>
<e-chart3d-series [dataSource]='dataSource' type='Column' xName='country' yName='gold'>
</e-chart3d-series>
<e-chart3d-series [dataSource]='dataSource' type='Column' xName='country' yName='silver'>
</e-chart3d-series>
<e-chart3d-series [dataSource]='dataSource' type='Column' xName='country' yName='bronze'>
</e-chart3d-series>
</e-chart3d-series-collection>
</ejs-chart3d>`
})
export class AppComponent {
public dataSource?: Object[];
public primaryXAxis?: Object;
public selection?: String;
public enableRotation?: boolean;
ngOnInit(): void {
this.dataSource = [
{ country: "USA", gold: 50, silver: 70, bronze: 45 },
{ country: "China", gold: 40, silver: 60, bronze: 55 },
{ country: "Japan", gold: 70, silver: 60, bronze: 50 },
{ country: "Australia", gold: 60, silver: 56, bronze: 40 },
{ country: "France", gold: 50, silver: 45, bronze: 35 },
{ country: "Germany", gold: 40, silver: 30, bronze: 22 },
{ country: "Italy", gold: 40, silver: 35, bronze: 37 },
{ country: "Sweden", gold: 30, silver: 25, bronze: 27 }
];
this.primaryXAxis = {
valueType: 'Category',
labelRotation: -45,
labelPlacement: 'BetweenTicks'
};
this.enableRotation = true;
this.selection = "Point";
}
}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { Chart3DAllModule} from '@syncfusion/ej2-angular-charts';
/**
* Module
*/
@NgModule({
imports: [
BrowserModule, Chart3DAllModule
],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule { }
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';
import 'zone.js';
enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);
Selection during initial loading
In a 3D chart, selecting a point or series during initial loading can only be done programmatically. The selectedDataIndexes
property can be used for this.
import { Component } from '@angular/core';
@Component({
selector: 'app-container',
// specifies the template string for the Chart component
template: `<ejs-chart3d style='display:block;' align='center' [primaryXAxis]='primaryXAxis' [selectionMode]="selection" [isMultiSelect]=true [selectedDataIndexes]="selectedDataIndexes"
rotation=7 tilt=10 depth=100 [enableRotation]='enableRotation'>
<e-chart3d-series-collection>
<e-chart3d-series [dataSource]='dataSource' type='Column' xName='country' yName='gold'>
</e-chart3d-series>
<e-chart3d-series [dataSource]='dataSource' type='Column' xName='country' yName='silver'>
</e-chart3d-series>
<e-chart3d-series [dataSource]='dataSource' type='Column' xName='country' yName='bronze'>
</e-chart3d-series>
</e-chart3d-series-collection>
</ejs-chart3d>`
})
export class AppComponent {
public dataSource?: Object[];
public selectedDataIndexes?: Object[];
public primaryXAxis?: Object;
public selection?: String;
public enableRotation?: boolean;
ngOnInit(): void {
this.dataSource = [
{ country: "USA", gold: 50, silver: 70, bronze: 45 },
{ country: "China", gold: 40, silver: 60, bronze: 55 },
{ country: "Japan", gold: 70, silver: 60, bronze: 50 },
{ country: "Australia", gold: 60, silver: 56, bronze: 40 },
{ country: "France", gold: 50, silver: 45, bronze: 35 },
{ country: "Germany", gold: 40, silver: 30, bronze: 22 },
{ country: "Italy", gold: 40, silver: 35, bronze: 37 },
{ country: "Sweden", gold: 30, silver: 25, bronze: 27 }
];
this.primaryXAxis = {
valueType: 'Category',
labelRotation: -45,
labelPlacement: 'BetweenTicks'
};
this.enableRotation = true;
this.selection = "Point";
this.selectedDataIndexes = [
{ series: 0, point: 1}, { series: 2, point: 3}
];
}
}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { Chart3DAllModule} from '@syncfusion/ej2-angular-charts';
/**
* Module
*/
@NgModule({
imports: [
BrowserModule, Chart3DAllModule
],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule { }
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';
import 'zone.js';
enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);
Selection through legend
To select a point or series through legend use the toggleVisibility
property. Also, use enableHighlight
property for highlighting the series through legend.
import { Component } from '@angular/core';
@Component({
selector: 'app-container',
// specifies the template string for the Chart component
template: `<ejs-chart3d style='display:block;' align='center' [primaryXAxis]='primaryXAxis' [legendSettings]="legend"
rotation=7 tilt=10 depth=100 [enableRotation]='enableRotation'>
<e-chart3d-series-collection>
<e-chart3d-series [dataSource]='dataSource' type='Column' xName='country' yName='gold' name="Gold">
</e-chart3d-series>
<e-chart3d-series [dataSource]='dataSource' type='Column' xName='country' yName='silver' name="Silver">
</e-chart3d-series>
<e-chart3d-series [dataSource]='dataSource' type='Column' xName='country' yName='bronze' name="Bronze">
</e-chart3d-series>
</e-chart3d-series-collection>
</ejs-chart3d>`
})
export class AppComponent {
public dataSource?: Object[];
public primaryXAxis?: Object;
public legend?: Object;
public enableRotation?: boolean;
ngOnInit(): void {
this.dataSource = [
{ country: "USA", gold: 50, silver: 70, bronze: 45 },
{ country: "China", gold: 40, silver: 60, bronze: 55 },
{ country: "Japan", gold: 70, silver: 60, bronze: 50 },
{ country: "Australia", gold: 60, silver: 56, bronze: 40 },
{ country: "France", gold: 50, silver: 45, bronze: 35 },
{ country: "Germany", gold: 40, silver: 30, bronze: 22 },
{ country: "Italy", gold: 40, silver: 35, bronze: 37 },
{ country: "Sweden", gold: 30, silver: 25, bronze: 27 }
];
this.primaryXAxis = {
valueType: 'Category',
labelRotation: -45,
labelPlacement: 'BetweenTicks'
};
this.enableRotation = true;
this.legend = {
visible: true,
toggleVisibility: false,
enableHighlight: true
}
}
}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { Chart3DAllModule} from '@syncfusion/ej2-angular-charts';
/**
* Module
*/
@NgModule({
imports: [
BrowserModule, Chart3DAllModule
],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule { }
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';
import 'zone.js';
enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);