diff options
| author | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-29 22:30:22 +0200 |
|---|---|---|
| committer | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-29 22:30:22 +0200 |
| commit | 323ac54b471ecf1abb7e6c881e86f57e157586a6 (patch) | |
| tree | c5799d223242aaf3c605f3f4df2e5e472dee780f /src/components/app/sidebars/elements | |
| parent | 4d45c4282af2da4e6b06b8d844dc333ccb83d343 (diff) | |
Download generated image files automatically
(instead of having them open in a new tab)
Diffstat (limited to 'src/components/app/sidebars/elements')
| -rw-r--r-- | src/components/app/sidebars/elements/LoadChartComponent.js | 11 |
1 files changed, 7 insertions, 4 deletions
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( <VictoryChartComponent data={data} currentTick={currentTick} showCurrentTick={false}/> - )); - 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 ( |
