mirror of
https://github.com/PeWu/topola-viewer.git
synced 2026-04-21 05:56:17 +00:00
lazy load jspdf to speed up page load
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import jsPDF from 'jspdf';
|
|
||||||
import {event, select, Selection} from 'd3-selection';
|
import {event, select, Selection} from 'd3-selection';
|
||||||
import {interpolateNumber} from 'd3-interpolate';
|
import {interpolateNumber} from 'd3-interpolate';
|
||||||
import {intlShape} from 'react-intl';
|
import {intlShape} from 'react-intl';
|
||||||
@@ -395,8 +394,10 @@ export class Chart extends React.PureComponent<ChartProps, {}> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async downloadPdf() {
|
async downloadPdf() {
|
||||||
|
// Lazy load jspdf.
|
||||||
|
const {default: jspdf} = await import('jspdf');
|
||||||
const canvas = await this.drawOnCanvas();
|
const canvas = await this.drawOnCanvas();
|
||||||
const doc = new jsPDF({
|
const doc = new jspdf({
|
||||||
orientation: canvas.width > canvas.height ? 'l' : 'p',
|
orientation: canvas.width > canvas.height ? 'l' : 'p',
|
||||||
unit: 'pt',
|
unit: 'pt',
|
||||||
format: [canvas.width, canvas.height],
|
format: [canvas.width, canvas.height],
|
||||||
|
|||||||
Reference in New Issue
Block a user