Skip to content

Commit 1157ba3

Browse files
committed
Make exported plots interactive
1 parent 207097e commit 1157ba3

File tree

4 files changed

+13
-27
lines changed

4 files changed

+13
-27
lines changed

package-lock.json

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/modules/ipc.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ipcMain, dialog } from "electron";
22
import fs from "fs";
3+
import path from "path";
34
import { parseFlightLog } from "./logparser.js"
45
import { exportFlightLogToCSVs } from "./flightlog.js"
56
import { connect, disconnect, command, cliCommand, getList } from "./serial.js";
@@ -74,17 +75,16 @@ export function subscribeListeners() {
7475
event.sender.send("EXPORT_FLIGHTLOG_CSVS");
7576
});
7677

77-
ipcMain.on("EXPORT_FLIGHTLOG_HTML", (event, flightLogHtmlStr) => {
78+
ipcMain.on("EXPORT_FLIGHTLOG_HTML", (event, flightLog, useImperialUnits) => {
79+
const flightlogJson = JSON.stringify(flightLog);
80+
const useImperialUnitsString = String(true);
7881

79-
flightLogHtmlStr = `
80-
<!DOCTYPE html>
81-
<html>
82-
<head>
83-
<script src="https://cdn.plot.ly/plotly-2.18.2.min.js"></script>
84-
</head>
85-
<body>
86-
` + flightLogHtmlStr + "</body></html>"
87-
fs.writeFile("plots.html", flightLogHtmlStr, 'utf8', function (err) {
82+
let plotsHTML = fs.readFileSync(path.join(__dirname, '../templates/plots.html'), 'utf8');
83+
84+
plotsHTML = plotsHTML.replace("/* FLIGHTLOG_PLACEHOLDER */", flightlogJson);
85+
plotsHTML = plotsHTML.replace("/* USE_IMPERIAL_UNITS_PLACEHOLDER */", useImperialUnitsString);
86+
87+
fs.writeFile("plots.html", plotsHTML, 'utf8', function (err) {
8888
if (err) {
8989
console.log("An error occurred while writing CSV Object to File.");
9090
return console.log(err);

src/modules/plots.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,6 @@
11
import Plotly from 'plotly.js-dist';
22
import { getDisplayValue } from "@/utils/unitConversions.js";
33

4-
const COLOR = "rgb(100, 100, 100)"
5-
const EVENT_MAP = {
6-
0: { name: "ev_moving", color: COLOR },
7-
1: { name: "ev_ready", color: COLOR },
8-
2: { name: "ev_liftoff", color: COLOR },
9-
3: { name: "ev_burnout", color: COLOR },
10-
4: { name: "ev_apogee", color: COLOR },
11-
5: { name: "ev_main_deployment", color: COLOR },
12-
6: { name: "ev_touchdown", color: COLOR },
13-
7: { name: "ev_custom1", color: COLOR },
14-
8: { name: "ev_custom2", color: COLOR },
15-
}
16-
174
function adaptTraceNameForConverterFunction(name) {
185
if (name === 'height') return 'altitude';
196
if (name === 'Ax') return 'acceleration';

src/views/Home.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export default {
131131
},
132132
exportFlightLogHtml() {
133133
this.exportButtonLoading = true;
134-
window.renderer.send("EXPORT_FLIGHTLOG_HTML", this.$refs.flightLogPlotContainer.innerHTML);
134+
window.renderer.send("EXPORT_FLIGHTLOG_HTML", this.flightLog, true);
135135
},
136136
setResizeTimer() {
137137
clearTimeout(this.resizeTimer)

0 commit comments

Comments
 (0)