From 4d45c4282af2da4e6b06b8d844dc333ccb83d343 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Fri, 29 Sep 2017 22:02:48 +0200 Subject: Add button for export of current chart to svg --- .../app/sidebars/elements/LoadChartComponent.js | 80 +++++++++++++++------- 1 file changed, 55 insertions(+), 25 deletions(-) (limited to 'src/components/app/sidebars') diff --git a/src/components/app/sidebars/elements/LoadChartComponent.js b/src/components/app/sidebars/elements/LoadChartComponent.js index 19d58f77..93664ab6 100644 --- a/src/components/app/sidebars/elements/LoadChartComponent.js +++ b/src/components/app/sidebars/elements/LoadChartComponent.js @@ -1,29 +1,47 @@ import React from "react"; +import ReactDOM from "react-dom/server"; import {VictoryAxis, VictoryChart, VictoryLine, VictoryScatter} from "victory"; import {convertSecondsToFormattedTime} from "../../../../util/date-time"; -const LoadChartComponent = ({data, currentTick}) => ( -
- Load over time - - convertSecondsToFormattedTime(tick)} - fixLabelOverlap={true} - label="Simulated Time" - /> - - - +const LoadChartComponent = ({data, currentTick}) => { + const onExport = () => { + const newWindow = window.open(""); + newWindow.document.write(ReactDOM.renderToString( + + )); + newWindow.document.title = "OpenDC Chart Export"; + }; + + return ( +
+ Load over time + + +
+ ); +}; + +const VictoryChartComponent = ({data, currentTick, showCurrentTick}) => ( + + convertSecondsToFormattedTime(tick)} + fixLabelOverlap={true} + label="Simulated Time" + /> + + + + {showCurrentTick ? ( style={{ data: {stroke: "#00A6D6", strokeWidth: 3} }} - /> - -
+ /> : + undefined + } + +); + +const ExportChartComponent = ({onExport}) => ( + ); export default LoadChartComponent; -- cgit v1.2.3