+
@@ -85,9 +85,21 @@ export default class WebRPlot extends Vue {
formatOnPaste: true,
}
+ private JSON_MONACO_EDITOR_OPTIONS = {
+ automaticLayout: true,
+ wordWrap: 'on',
+ minimap: { enabled: false },
+ showFoldingControls: 'always',
+ folding: true,
+ foldingStrategy: 'indentation',
+ }
+
private editorRef: ShallowRef = shallowRef();
private jsonEditor: ShallowRef = shallowRef();
+ private shelter = null;
+ private webr = null;
+
handleMount(editor: any) {
this.editorRef = editor;
}
@@ -102,19 +114,20 @@ export default class WebRPlot extends Vue {
async plot() {
+ const webr = new WebR({interactive: false});
this.loadingMsg = "Loading webR environment";
+ await webr.init();
- const webR = new WebR({interactive: false});
- await webR.init();
+ //this.shelter = await new WebR.Shelter();
// bind dataset json data into R environment
console.log(JSON.stringify(this.data));
this.jsonData = JSON.stringify(this.data);
- await webR.objs.globalEnv.bind('jsonStr', JSON.stringify(this.data));
+ await webr.objs.globalEnv.bind('jsonStr', JSON.stringify(this.data));
this.loadingMsg = "Installing webR packages";
- await webR.installPackages(['jsonlite', 'ggplot2', 'plotly'], true);
+ await webr.installPackages(['jsonlite', 'ggplot2', 'plotly'], true);
this.loadingMsg = "Fetching widget source code";
@@ -126,13 +139,40 @@ export default class WebRPlot extends Vue {
console.log(this.code);
this.loadingMsg = "Running R code";
- const plotlyData = await webR.evalRString(this.code);
+ const plotlyData = await webr.evalRString(this.code);
this.loading = false;
Plotly.newPlot('out', JSON.parse(plotlyData), {});
+
+ // TODO: this is causing an error on the console
+ this.webr = webr;
}
- runCode() {
+ async runCode() {
+ console.log(this.codeM);
+
+ // TODO: manage resources properly, shelter?
+ /*
+ const result = await this.shelter.captureR(this.codeM, {
+ withAutoprint: true,
+ captureStreams: true,
+ captureConditions: false
+ });
+
+ console.log(result);
+ */
+
+
+ const plotlyData = await this.webr.evalRString(this.codeM);
+ console.log(plotlyData);
+
+ Plotly.newPlot('out', JSON.parse(plotlyData), {});
+
+ // TODO: isn't working
+ Plotly.relayout('out', {
+ 'xaxis.autorange': true,
+ 'yaxis.autorange': true
+ });
}
From 0ddd2088d0e8f2af18f001ca265afef057e920ea Mon Sep 17 00:00:00 2001
From: Nick <53413353+nickpalladino@users.noreply.github.com>
Date: Sun, 24 Mar 2024 00:08:13 -0400
Subject: [PATCH 09/10] Added loading indicator when running edited code
---
src/components/analysis/WebRPlot.vue | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/components/analysis/WebRPlot.vue b/src/components/analysis/WebRPlot.vue
index bce1580ec..ad64cb064 100644
--- a/src/components/analysis/WebRPlot.vue
+++ b/src/components/analysis/WebRPlot.vue
@@ -48,7 +48,7 @@