From 66400677109f93776264b2fc3f03c4022861a706 Mon Sep 17 00:00:00 2001 From: minjk-bl Date: Mon, 20 Jun 2022 13:10:02 +0900 Subject: [PATCH 01/25] Add inline code on Chart Style --- js/m_visualize/ChartSetting.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/m_visualize/ChartSetting.js b/js/m_visualize/ChartSetting.js index 29cea980..612bd2e8 100644 --- a/js/m_visualize/ChartSetting.js +++ b/js/m_visualize/ChartSetting.js @@ -75,7 +75,6 @@ define([ var code = new com_String(); // FIXME: convert it to kernelApi code.appendLine('import matplotlib.pyplot as plt'); - code.appendLine('%matplotlib inline'); code.appendLine('import json'); code.append(`print(json.dumps([{ 'label': s, 'value': s } for s in plt.style.available]))`); vpKernel.execute(code.toString()).then(function(resultObj) { @@ -125,8 +124,8 @@ define([ generateImportCode() { var code = new com_String(); code.appendLine('import matplotlib.pyplot as plt'); - code.appendLine('import seaborn as sns'); code.append('%matplotlib inline'); + code.appendLine('import seaborn as sns'); return [code.toString()]; } @@ -143,6 +142,7 @@ define([ let { figureWidth, figureHeight, styleSheet, fontName, fontSize } = this.state; code.appendLine('import matplotlib.pyplot as plt'); + code.appendLine('%matplotlib inline'); code.appendLine('import seaborn as sns'); code.appendFormatLine("plt.rc('figure', figsize=({0}, {1}))", figureWidth, figureHeight); if (styleSheet && styleSheet.length > 0) { From 1104e91f1d0396313a1ac647ddf9df81294d3aa7 Mon Sep 17 00:00:00 2001 From: minjk-bl Date: Mon, 20 Jun 2022 13:28:43 +0900 Subject: [PATCH 02/25] Fix bug: generated code bug on Markdown app --- js/com/component/PopupComponent.js | 1 + js/m_apps/Markdown.js | 14 +++----------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/js/com/component/PopupComponent.js b/js/com/component/PopupComponent.js index 58472afc..4aad180e 100644 --- a/js/com/component/PopupComponent.js +++ b/js/com/component/PopupComponent.js @@ -683,6 +683,7 @@ define([ let code = this.generateCode(); let mode = this.config.executeMode; let sigText = ''; + vpLog.display(VP_LOG_TYPE.DEVELOP, sigText, mode, code); // check if it's block if (this.getTaskType() == 'block') { let block = this.taskItem; diff --git a/js/m_apps/Markdown.js b/js/m_apps/Markdown.js index 405f64c7..ebd16e22 100644 --- a/js/m_apps/Markdown.js +++ b/js/m_apps/Markdown.js @@ -126,7 +126,7 @@ define([ var page = new com_String(); page.appendLine('
'); page.appendLine(this.templateForToolbar()); - page.appendFormatLine('', 'vp_markdownEditor', this.state.editor); + page.appendFormatLine('', 'vp_markdownEditor', this.state.editor); page.appendFormatLine('
', "vp_attachEncodedDataArea"); page.appendLine('
'); page.appendFormatLine('
{1}
', 'vp_markdownPreview', this.state.preview); @@ -148,10 +148,6 @@ define([ `; } - templateForDataView() { - return ``; - } - render() { super.render(); @@ -213,14 +209,9 @@ define([ preview = ''; } that.state.preview = preview; - document.getElementById("vp_markdownPreview").innerHTML = preview; + $(that.wrapSelector("#vp_markdownPreview")).html(preview); MathJax.Hub.Queue(["Typeset", MathJax.Hub, "vp_markdownPreview"]); - - // re render block - if (block) { - block.render(); - } }); } @@ -306,6 +297,7 @@ define([ // repace selection cm.replaceSelection(adjustText); // TODO: set block code + cm.focus(); } /** From f85d2e03d03c12caf0cd239eb990daee1cff97f4 Mon Sep 17 00:00:00 2001 From: minjk-bl Date: Mon, 20 Jun 2022 13:45:07 +0900 Subject: [PATCH 03/25] Add test code for user code on Plotly app --- html/m_visualize/plotly.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/m_visualize/plotly.html b/html/m_visualize/plotly.html index eca3692c..b172981d 100644 --- a/html/m_visualize/plotly.html +++ b/html/m_visualize/plotly.html @@ -87,7 +87,7 @@ From e4ff2e5fda896c3f1f6009db7df84491e553f826 Mon Sep 17 00:00:00 2001 From: minjk-bl Date: Mon, 20 Jun 2022 13:55:16 +0900 Subject: [PATCH 04/25] Fix to refresh preview for bluring textarea on Seaborn, Plotly app --- js/m_visualize/Plotly.js | 25 ++++--------------------- js/m_visualize/Seaborn.js | 2 +- 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/js/m_visualize/Plotly.js b/js/m_visualize/Plotly.js index b272ca92..a7d9c664 100644 --- a/js/m_visualize/Plotly.js +++ b/js/m_visualize/Plotly.js @@ -25,23 +25,6 @@ define([ 'vp_base/data/m_visualize/plotlyLibrary', ], function(ptHTML, ptCss, com_String, com_generator, com_util, PopupComponent, SuggestInput, FileNavigation, DataSelector, PLOTLY_LIBRARIES) { - /** - * TODO: libraries.json add menu - * { - "id" : "visualize_plotly", - "type" : "function", - "level": 1, - "name" : "Plotly", - "tag" : "PLOTLY,VISUALIZATION,VISUALIZE", - "path" : "visualpython - visualization - plotly", - "desc" : "Plotly express", - "file" : "m_visualize/Plotly", - "apps" : { - "color": 5, - "icon": "apps/apps_visualize.svg" - } - }, - */ class Plotly extends PopupComponent { _init() { super._init(); @@ -391,7 +374,7 @@ define([ key: userCodeKey, selector: userCodeTarget, events: [{ - key: 'change', + key: 'blur', callback: function(instance, evt) { // save its state instance.save(); @@ -499,12 +482,12 @@ define([ let generatedCode = com_generator.vp_codeGenerator(this, config, this.state , etcOptionCode.length > 0? ', ' + etcOptionCode.join(', '): ''); - code.append(generatedCode); + code.appendFormatLine("fig = {0}", generatedCode); if (userCode && userCode != '') { - code.appendLine(); - code.append(userCode); + code.appendLine(userCode); } + code.append('fig.show()'); return code.toString(); } diff --git a/js/m_visualize/Seaborn.js b/js/m_visualize/Seaborn.js index e7ccc2e4..a5efa3ce 100644 --- a/js/m_visualize/Seaborn.js +++ b/js/m_visualize/Seaborn.js @@ -526,7 +526,7 @@ define([ key: userCodeKey, selector: userCodeTarget, events: [{ - key: 'change', + key: 'blur', callback: function(instance, evt) { // save its state instance.save(); From c0e44861426c9f092cff4616db9380cf654251eb Mon Sep 17 00:00:00 2001 From: minjk-bl Date: Mon, 20 Jun 2022 14:19:57 +0900 Subject: [PATCH 05/25] Add x_label, y_label option on Plotly app --- html/m_visualize/plotly.html | 17 ++++++++++++- js/m_visualize/Plotly.js | 46 ++++++++++++++++++++++++++++++++++-- 2 files changed, 60 insertions(+), 3 deletions(-) diff --git a/html/m_visualize/plotly.html b/html/m_visualize/plotly.html index b172981d..be4f6a85 100644 --- a/html/m_visualize/plotly.html +++ b/html/m_visualize/plotly.html @@ -70,6 +70,12 @@ + +
+ +
@@ -79,7 +85,16 @@