Export print in EJ2 JavaScript Range navigator control

8 May 20235 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.
var range = new ej.charts.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 }
        }
    ],
}, 'element');
document.getElementById('export').onclick = function () {
    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://cdn.syncfusion.com/ej2/25.1.35/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>

<body>
    
    <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>


<script>
var ele = document.getElementById('container');
if(ele) {
  ele.style.visibility = "visible";
}   
      </script>
<script src="index.js" type="text/javascript"></script>
</body></html>

Print

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

var range = new ej.charts.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 }
        }
    ],
}, 'element');
document.getElementById('export').onclick = function () {
    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://cdn.syncfusion.com/ej2/25.1.35/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>

<body>
    
    <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>


<script>
var ele = document.getElementById('container');
if(ele) {
  ele.style.visibility = "visible";
}   
      </script>
<script src="index.js" type="text/javascript"></script>
</body></html>