summaryrefslogtreecommitdiff
path: root/src/components/app/sidebars
diff options
context:
space:
mode:
authorGeorgios Andreadis <g.andreadis@student.tudelft.nl>2017-09-29 22:30:22 +0200
committerGeorgios Andreadis <g.andreadis@student.tudelft.nl>2017-09-29 22:30:22 +0200
commit323ac54b471ecf1abb7e6c881e86f57e157586a6 (patch)
treec5799d223242aaf3c605f3f4df2e5e472dee780f /src/components/app/sidebars
parent4d45c4282af2da4e6b06b8d844dc333ccb83d343 (diff)
Download generated image files automatically
(instead of having them open in a new tab)
Diffstat (limited to 'src/components/app/sidebars')
-rw-r--r--src/components/app/sidebars/elements/LoadChartComponent.js11
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 (