Search results

Export and Print in Angular Range Navigator component

27 Oct 2021 / 2 minutes to read

Export

The rendered Range Selector can be exported to JPEG, PNG, SVG, or PDF format by using the export method in the Range Selector. This method contains the following parameters:

  • Type - To specify the export type. The component can be exported to JPEG, PNG, SVG, or PDF format.
  • File name - To specify the file name to export.
  • Orientation - To specify the orientation type. This is applicable only for PDF export type.
Source
Preview
app.component.ts
app.module.ts
main.ts
Copied to clipboard
import { Component, OnInit, ViewChild } from '@angular/core';
import { bitCoinData } from 'datasource.ts';
import { ButtonComponent } from '@syncfusion/ej2-angular-buttons';
import { RangeNavigatorComponent } from '@syncfusion/ej2-angular-charts';

@Component({
selector: 'app-container',
template:
`<button ej-button id='print' (click)='export()'>Export</button>
<ejs-rangenavigator #range id="range" valueType='DateTime' [value]='value'>
        <e-rangenavigator-series-collection>
            <e-rangenavigator-series [dataSource]='chartData' type='Area' xName='x' yName='y' width=2>
            </e-rangenavigator-series>
        </e-rangenavigator-series-collection>
    </ejs-rangenavigator>`
})
export class AppComponent implements OnInit {
@ViewChild('range')
public RangeObj: RangeNavigatorComponent;

public periodsValue: Object[];
public chartData: Object[];
public value: Object[];
ngOnInit(): void {
    this.chartData = bitCoinData;
    this.value=[new Date(2017, 8, 1), new Date(2018, 1, 1)];
}
export() {
     this.RangeObj.export('PNG', 'result',  null, [this.RangeObj]);
}
}
Copied to clipboard
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { ChartModule, RangeNavigatorModule } from '@syncfusion/ej2-angular-charts';
import { AreaSeriesService, DateTimeService, StepLineSeriesService} from '@syncfusion/ej2-angular-charts';

/**
 * Module
 */
@NgModule({
    imports: [
        BrowserModule, ChartModule, RangeNavigatorModule
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent],
    providers: [ AreaSeriesService, DateTimeService, StepLineSeriesService ]
})
export class AppModule { }
Copied to clipboard
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';

enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);

Print

The rendered Range Selector can be printed directly from the browser by calling the public method print.

Source
Preview
app.component.ts
app.module.ts
main.ts
Copied to clipboard
import { Component, OnInit, ViewChild } from '@angular/core';
import { bitCoinData } from 'datasource.ts';
import { ButtonComponent } from '@syncfusion/ej2-angular-buttons';
import { RangeNavigatorComponent } from '@syncfusion/ej2-angular-charts';

@Component({
selector: 'app-container',
template:
`<button ej-button id='print' (click)='print()'>Print</button>
<ejs-rangenavigator #range id="range" valueType='DateTime' [value]='value'>
        <e-rangenavigator-series-collection>
            <e-rangenavigator-series [dataSource]='chartData' type='Area' xName='x' yName='y' width=2>
            </e-rangenavigator-series>
        </e-rangenavigator-series-collection>
    </ejs-rangenavigator>`
})
export class AppComponent implements OnInit {
@ViewChild('range')
public RangeObj: RangeNavigatorComponent;

public periodsValue: Object[];
public chartData: Object[];
public value: Object[];
ngOnInit(): void {
    this.chartData = bitCoinData;
    this.value=[new Date(2017, 8, 1), new Date(2018, 1, 1)];
}
print() {
    this.RangeObj.print();
}
}
Copied to clipboard
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { ChartModule, RangeNavigatorModule } from '@syncfusion/ej2-angular-charts';
import { AreaSeriesService, DateTimeService, StepLineSeriesService} from '@syncfusion/ej2-angular-charts';

/**
 * Module
 */
@NgModule({
    imports: [
        BrowserModule, ChartModule, RangeNavigatorModule
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent],
    providers: [ AreaSeriesService, DateTimeService, StepLineSeriesService ]
})
export class AppModule { }
Copied to clipboard
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';

enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);
Contents
Contents