Export print in EJ2 TypeScript Range navigator control

8 May 20236 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 { SplineSeries, AreaSeries, DateTime, Crosshair } from '@syncfusion/ej2-charts';
import { RangeNavigator, Chart, IChangedEventArgs } from '@syncfusion/ej2-charts';
import {  RangeTooltip, Tooltip } from '@syncfusion/ej2-charts';
import { bitCoinData } from './datasource.ts';
RangeNavigator.Inject(AreaSeries, DateTime, RangeTooltip);

let range: RangeNavigator = new RangeNavigator(
    {
        valueType: 'DateTime',
        value: [new Date(2017, 8, 1), new Date(2018, 1, 1)],
        tooltip: { enable: true },
        series: [
            {
                dataSource: bitCoinData, xName: 'x', yName: 'y', type: 'Area',
                width: 2, animation: { enable: false }
            }
        ],
    }
);
range.appendTo('#element');

 document.getElementById('export').onclick = () => {
        range.export('PNG', 'result',  null, [range]);
    };
<!DOCTYPE html>
<html lang="en">

<head>
    <title>EJ2 Animation</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="Typescript UI Controls" />
    <meta name="author" content="Syncfusion" />
    <link href="index.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>

<body>
    <div id='loader'>Loading....</div>
    <div id='container' style="margin-top: 125px">
        <div id='element'></div>
        <div id='chart'></div>
        <button id= "export" type="button" width ='15%' style="float: right">Export</button>
    </div>
</body>

</html>

Print

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

import { SplineSeries, AreaSeries, DateTime, Crosshair } from '@syncfusion/ej2-charts';
import { RangeNavigator, Chart, IChangedEventArgs } from '@syncfusion/ej2-charts';
import {  RangeTooltip, Tooltip } from '@syncfusion/ej2-charts';
import { bitCoinData } from './datasource.ts';
RangeNavigator.Inject(AreaSeries, DateTime, RangeTooltip);

let range: RangeNavigator = new RangeNavigator(
    {
        valueType: 'DateTime',
        value: [new Date(2017, 8, 1), new Date(2018, 1, 1)],
        tooltip: { enable: true },
        series: [
            {
                dataSource: bitCoinData, xName: 'x', yName: 'y', type: 'Area',
                width: 2, animation: { enable: false }
            }
        ],
    }
);
range.appendTo('#element');

  document.getElementById('print').onclick = () => {
        range.print();
    };
<!DOCTYPE html>
<html lang="en">

<head>
    <title>EJ2 Animation</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="Typescript UI Controls" />
    <meta name="author" content="Syncfusion" />
    <link href="index.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>

<body>
    <div id='loader'>Loading....</div>
    <div id='container' style="margin-top: 125px">
        <div id='element'></div>
        <div id='chart'></div>
        <button id= "print" type="button" width ='15%' style="float: right">Print</button>
    </div>
</body>

</html>