diff --git a/src/states/Sensor.js b/src/states/Sensor.js index f9107f4..1906141 100644 --- a/src/states/Sensor.js +++ b/src/states/Sensor.js @@ -445,7 +445,9 @@ class Sensor extends Component { } export_PDF() { this.setState({ ...this.state, graphPDFMode: true }); - exportPDF(this.props.sensor, this.state.data, this.getGraphData(), this.state.graphKey, this.state.from, this.chartRef, this.props.t, () => { + let from = this.getFrom() + let to = this.state.to || new Date().getTime() + exportPDF(this.props.sensor, this.state.data, this.getGraphData(), this.state.graphKey, from, to, this.chartRef, this.props.t, () => { this.setState({ ...this.state, graphPDFMode: false }) }) } diff --git a/src/utils/export.js b/src/utils/export.js index 235a52a..7d40cb4 100644 --- a/src/utils/export.js +++ b/src/utils/export.js @@ -120,7 +120,7 @@ export function exportXLSX(dataIn, sensorName, t) { XLSX.writeFile(wb, exportedFilename); } -export function exportPDF(sensor, data, graphData, type, from, chartRef, t, done) { +export function exportPDF(sensor, data, graphData, type, from, to, chartRef, t, done) { let ezdata = []; for (let i = 0; i < graphData.length; i++) { if (graphData[i].parsed === null) continue @@ -181,7 +181,7 @@ export function exportPDF(sensor, data, graphData, type, from, chartRef, t, done var d = new Date(ts); return d.getDate() + "." + (d.getMonth() + 1) + "." + (d.getFullYear()) } - let text_date = t("dates") + `: ${dateToit(new Date().getTime() - from * 60 * 60 * 1000)} - ${dateToit(new Date())}` + let text_date = t("dates") + `: ${dateToit(from)} - ${dateToit(to)}` doc.text(text_date, width - doc.getTextWidth(text_date) - padding, linePos + lineBottomPadding + doc.getTextDimensions(text_date).h + 1.2) //doc.text("Note:", padding, linePos + 20)