Skip to content

Commit 0c26dd9

Browse files
author
minjk-bl
committed
Fix Chart
1 parent a0cc717 commit 0c26dd9

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

css/matplotlib/plot.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
.vp-icon-btn.vp-close-view {
3535
position: absolute;
36-
right: 20px;
36+
right: 10px;
3737
cursor: pointer;
3838
}
3939
.vp-option-title {

src/api_block/init.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,27 @@ define([
378378
blockContainer.addNodeBlock(createdBlock);
379379
blockContainer.resetBlockList();
380380
blockContainer.reRenderAllBlock_asc();
381-
}
381+
} else if (title == "Background") {
382+
// 1. add code block
383+
// create block as group block
384+
createdBlock = blockContainer.createBlock(BLOCK_CODELINE_TYPE.CODE, null, null, true);
385+
// set code
386+
createdBlock.setState({
387+
[STATE_codeLine]: code
388+
});
389+
createdBlock.writeCode(code);
390+
createdBlock.apply();
391+
if (isFirstBlock == true) {
392+
// if it is first block, set as ROOT
393+
createdBlock.setDirection(BLOCK_DIRECTION.ROOT);
394+
} else {
395+
var lastBottomBlock = blockContainer.getRootToLastBottomBlock();
396+
lastBottomBlock.appendBlock(createdBlock, BLOCK_DIRECTION.DOWN);
397+
}
398+
blockContainer.addNodeBlock(createdBlock);
399+
blockContainer.resetBlockList();
400+
blockContainer.reRenderAllBlock_asc();
401+
}
382402
}
383403

384404
// 2. add cell and run cell

src/matplotlib/plot.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,6 @@ define([
130130
// accBoxImport.setOpenBox(true);
131131
sbTagString.clear();
132132
sbTagString.appendFormatLine('<div class="{0}">', 'vp-import-box');
133-
// import
134-
sbTagString.appendLine('<div>');
135-
sbTagString.appendFormatLine('<label for="{0}" class="{1}">{2}</label>', 'vp_plImport', '', 'Matplot.pyplot as');
136-
sbTagString.appendFormatLine('<input type="text" id="{0}" placeholder="{1}" value="{2}" disabled>', 'vp_plImport', 'alias', 'plt');
137-
sbTagString.appendLine('</div>');
138133
// figure size
139134
sbTagString.appendLine('<div>');
140135
sbTagString.appendFormatLine('<label for="{0}" class="{1}">{2}</label>', 'vp_plFigureWidth', '', 'Figure size');
@@ -160,7 +155,7 @@ define([
160155
sbTagString.appendLine('</div>');
161156
// import button
162157
sbTagString.appendLine('<div>');
163-
sbTagString.appendFormatLine('<input type="button" id="{0}" class="{1}" value="{2}">', 'vp_plImportRun', 'vp-button activated vp-pl-import-run', 'Import');
158+
sbTagString.appendFormatLine('<input type="button" id="{0}" class="{1}" value="{2}">', 'vp_plImportRun', 'vp-button activated vp-pl-import-run', 'Apply');
164159
sbTagString.appendLine('</div>');
165160

166161
sbTagString.appendLine('</div>');
@@ -468,7 +463,7 @@ define([
468463
// run cell
469464
$(vpCommon.wrapSelector('#vp_appsCode')).trigger({
470465
type: 'popup_run',
471-
title: 'Snippets',
466+
title: 'Background',
472467
code: code,
473468
addCell: true,
474469
runCell: true
@@ -1098,14 +1093,12 @@ define([
10981093
var code = new sb.StringBuilder();
10991094

11001095
// get parameters
1101-
var alias = $(this.wrapSelector('#vp_plImport')).val();
11021096
var figWidth = $(this.wrapSelector('#vp_plFigureWidth')).val();
11031097
var figHeight = $(this.wrapSelector('#vp_plFigureHeight')).val();
11041098
var styleName = $(this.wrapSelector('#vp_plStyle')).val();
11051099
var fontName = $(this.wrapSelector('#vp_plFontName')).val();
11061100
var fontSize = $(this.wrapSelector('#vp_plFontSize')).val();
11071101

1108-
code.appendLine('import matplotlib.pyplot as plt');
11091102
code.appendFormatLine("plt.rc('figure', figsize=({0}, {1}))", figWidth, figHeight);
11101103
if (styleName && styleName.length > 0) {
11111104
code.appendFormatLine("plt.style.use('{0}')", styleName);

0 commit comments

Comments
 (0)