Export print in Angular Range navigator component

20 Sep 20226 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.
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]);
    }
}
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 { }
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.

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();
    }
}
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 { }
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';

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