From 323ac54b471ecf1abb7e6c881e86f57e157586a6 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Fri, 29 Sep 2017 22:30:22 +0200 Subject: Download generated image files automatically (instead of having them open in a new tab) --- src/components/app/sidebars/elements/LoadChartComponent.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/components/app/sidebars/elements') diff --git a/src/components/app/sidebars/elements/LoadChartComponent.js b/src/components/app/sidebars/elements/LoadChartComponent.js index 93664ab6..13c700db 100644 --- a/src/components/app/sidebars/elements/LoadChartComponent.js +++ b/src/components/app/sidebars/elements/LoadChartComponent.js @@ -1,15 +1,18 @@ import React from "react"; import ReactDOM from "react-dom/server"; +import SvgSaver from "svgsaver"; import {VictoryAxis, VictoryChart, VictoryLine, VictoryScatter} from "victory"; import {convertSecondsToFormattedTime} from "../../../../util/date-time"; const LoadChartComponent = ({data, currentTick}) => { const onExport = () => { - const newWindow = window.open(""); - newWindow.document.write(ReactDOM.renderToString( + const div = document.createElement("div"); + div.innerHTML = ReactDOM.renderToString( - )); - newWindow.document.title = "OpenDC Chart Export"; + ); + div.firstChild.style = "font-family: Roboto, Arial, sans-serif; font-size: 10pt;"; + const svgSaver = new SvgSaver(); + svgSaver.asSvg(div.firstChild); }; return ( -- cgit v1.2.3