diff --git a/html/popupComponent.html b/html/popupComponent.html
index 1b4fafb7..531b89dd 100644
--- a/html/popupComponent.html
+++ b/html/popupComponent.html
@@ -50,6 +50,10 @@
+
+ Install Package
+
+
Import Library
diff --git a/js/com/com_Kernel.js b/js/com/com_Kernel.js
index 95951515..b049a100 100644
--- a/js/com/com_Kernel.js
+++ b/js/com/com_Kernel.js
@@ -141,6 +141,19 @@ define([
})
});
}
+
+ getColumnCategory(dataframe, columnName) {
+ var that = this;
+ return new Promise(function(resolve, reject) {
+ that.execute(com_util.formatString('_vp_print(_vp_get_column_category({0}, {1}))', dataframe, columnName))
+ .then(function(resultObj) {
+ resolve(resultObj);
+ }).catch(function(err) {
+ // reject
+ reject(err);
+ })
+ });
+ }
getRowList(dataframe) {
var that = this;
diff --git a/js/com/com_generator.js b/js/com/com_generator.js
index c3ec004c..2239886c 100644
--- a/js/com/com_generator.js
+++ b/js/com/com_generator.js
@@ -249,6 +249,9 @@ define([
suggestInput.setSuggestList(function() { return varList; });
suggestInput.setNormalFilter(false);
suggestInput.setValue($(divTag + ' #' + obj.name).val());
+ if (obj.placeholder != undefined) {
+ suggestInput.setPlaceholder(obj.placeholder);
+ }
suggestInput.setSelectEvent(function(selectedValue) {
// trigger change
$(divTag + ' #' + obj.name).val(selectedValue);
diff --git a/js/com/com_generatorV2.js b/js/com/com_generatorV2.js
index 7299935c..f97cdd58 100644
--- a/js/com/com_generatorV2.js
+++ b/js/com/com_generatorV2.js
@@ -322,8 +322,11 @@ define([
suggestInput.setComponentID(obj.name);
suggestInput.addClass('vp-input vp-state');
suggestInput.setSuggestList(function() { return obj.options; });
- suggestInput.setNormalFilter(true);
+ suggestInput.setNormalFilter(obj.useFilter == undefined?false:obj.useFilter);
suggestInput.setValue(value);
+ if (obj.placeholder != undefined) {
+ suggestInput.setPlaceholder(obj.placeholder);
+ }
suggestInput.setSelectEvent(function(selectedValue) {
// trigger change
$(pageThis.wrapSelector('#' + obj.name)).val(selectedValue);
@@ -454,6 +457,9 @@ define([
suggestInput.setSuggestList(function() { return varList; });
suggestInput.setNormalFilter(false);
suggestInput.setValue(defaultValue);
+ if (obj.placeholder != undefined) {
+ suggestInput.setPlaceholder(obj.placeholder);
+ }
suggestInput.setSelectEvent(function(selectedValue) {
// trigger change
$(divTag + ' #' + obj.name).val(selectedValue);
@@ -529,7 +535,13 @@ define([
*/
var vp_getTagValue = function(pageThis, obj) {
var value = '';
- switch (obj.component) {
+ let componentType = 'input';
+ if (obj.component && obj.component.length == 1) {
+ componentType = obj.component[0];
+ } else {
+ componentType = $(pageThis.wrapSelector('#' + obj.name + '_type')).val();
+ }
+ switch (componentType) {
case 'option_radio':
var input = $(pageThis.wrapSelector("input[name='"+obj.name+"']:checked")).val();
// same as default
@@ -545,7 +557,6 @@ define([
value = value.substr(0, value.length-1);
break;
case 'input_multi':
- case 'option_suggest':
case 'bool_select':
case 'var_select':
case 'var_multi':
@@ -556,6 +567,7 @@ define([
case 'table':
case 'file':
case 'option_select':
+ case 'option_suggest':
case 'input_number':
default:
var input = $(pageThis.wrapSelector('#'+obj.name)).val();
@@ -582,6 +594,9 @@ define([
if (val == undefined || val == '') {
val = vp_getTagValue(pageThis, v);
}
+ if (val == v.default) {
+ val = '';
+ }
var id = '${' + v.name + '}';
if (val == undefined || val.trim() == '') {
if (v.required == true) {
diff --git a/js/com/component/PopupComponent.js b/js/com/component/PopupComponent.js
index 2ac4b553..4c5dbac7 100644
--- a/js/com/component/PopupComponent.js
+++ b/js/com/component/PopupComponent.js
@@ -54,6 +54,7 @@ define([
sizeLevel: 0, // 0: 400x400 / 1: 500x500 / 2: 600x500 / 3: 750x500
executeMode: 'code', // cell execute mode
// show header bar buttons
+ installButton: false, // install button (#popupInstall) // FIXME: after creating packagemanager, deprecate it
importButton: false, // import library button (#popupImport)
packageButton: false, // package manager button (#popupPackage)
// show view box
@@ -257,6 +258,15 @@ define([
});
});
+ // Click install package
+ $(this.wrapSelector('#popupInstall')).on('click', function() {
+ // add install codes
+ var codes = that.generateInstallCode();
+ codes && codes.forEach(code => {
+ com_interface.insertCell('code', code);
+ });
+ });
+
// Click import library
$(this.wrapSelector('#popupImport')).on('click', function() {
// add import codes
@@ -475,12 +485,15 @@ define([
super.render(inplace);
let {
- importButton, packageButton,
+ installButton, importButton, packageButton,
codeview, dataview, runButton, footer,
sizeLevel, position
} = this.config;
// import & package manager button hide/show
+ if (!installButton) { // FIXME: Deprecated after creating package manager
+ $(this.wrapSelector('#popupInstall')).hide();
+ }
if (!importButton) {
$(this.wrapSelector('#popupImport')).hide();
}
@@ -574,6 +587,15 @@ define([
$('.vp-popup-dataview-box').html(this.templateForDataView());
}
+ /**
+ * Generated on clicking Install Package button
+ * @returns Array of installment codes
+ */
+ generateInstallCode() {
+ /** Implementation needed - Generated on clicking Install Package button */
+ return [];
+ }
+
generateImportCode() {
/** Implementation needed - Generated on clicking Import Library button */
return '';
diff --git a/js/m_apps/Bind.js b/js/m_apps/Bind.js
index 21a59979..55473f49 100644
--- a/js/m_apps/Bind.js
+++ b/js/m_apps/Bind.js
@@ -78,7 +78,7 @@ define([
$(document).off('change', this.wrapSelector('#vp_bdType'));
$(document).off('change', this.wrapSelector('#vp_bdVariable'));
- $(document).off('click', this.wrapSelector('#vp_bdVariableSelect'));
+ $(document).off('click', this.wrapSelector('#vp_bdVariable'));
$(document).off('change', this.wrapSelector('#vp_bdJoin'));
$(document).off('change', this.wrapSelector('#vp_bdAxis'));
$(document).off('change', this.wrapSelector('#vp_bdSort'));
@@ -88,12 +88,12 @@ define([
$(document).off('click', this.wrapSelector('.vp-bd-df-refresh'));
$(document).off('change', this.wrapSelector('#vp_bdHow'));
$(document).off('change', this.wrapSelector('#vp_bdOn'));
- $(document).off('click', this.wrapSelector('#vp_bdOnSelect'));
+ $(document).off('click', this.wrapSelector('#vp_bdOn'));
$(document).off('change', this.wrapSelector('#vp_bdLeftOn'));
- $(document).off('click', this.wrapSelector('#vp_bdLeftOnSelect'));
+ $(document).off('click', this.wrapSelector('#vp_bdLeftOn'));
$(document).off('change', this.wrapSelector('#vp_gbLeftIndex'));
$(document).off('change', this.wrapSelector('#vp_bdRightOn'));
- $(document).off('click', this.wrapSelector('#vp_bdRightOnSelect'));
+ $(document).off('click', this.wrapSelector('#vp_bdRightOn'));
$(document).off('change', this.wrapSelector('#vp_gbRightIndex'));
$(document).off('change', this.wrapSelector('#vp_bdLeftSuffix'));
$(document).off('change', this.wrapSelector('#vp_bdRightSuffix'));
@@ -133,7 +133,7 @@ define([
});
// variable select button event
- $(document).on('click', this.wrapSelector('#vp_bdVariableSelect'), function() {
+ $(document).on('click', this.wrapSelector('#vp_bdVariable'), function() {
that.openVariablePopup($(that.wrapSelector('#vp_bdVariable')));
});
@@ -196,20 +196,20 @@ define([
that.state.merge.on = colList;
if (colList && colList.length > 0) {
- $(that.wrapSelector('#vp_bdLeftOnSelect')).attr('disabled', true);
- $(that.wrapSelector('#vp_bdRightOnSelect')).attr('disabled', true);
+ $(that.wrapSelector('#vp_bdLeftOn')).attr('disabled', true);
+ $(that.wrapSelector('#vp_bdRightOn')).attr('disabled', true);
$(that.wrapSelector('#vp_bdLeftIndex')).attr('disabled', true);
$(that.wrapSelector('#vp_bdRightIndex')).attr('disabled', true);
} else {
- $(that.wrapSelector('#vp_bdLeftOnSelect')).attr('disabled', false);
- $(that.wrapSelector('#vp_bdRightOnSelect')).attr('disabled', false);
+ $(that.wrapSelector('#vp_bdLeftOn')).attr('disabled', false);
+ $(that.wrapSelector('#vp_bdRightOn')).attr('disabled', false);
$(that.wrapSelector('#vp_bdLeftIndex')).attr('disabled', false);
$(that.wrapSelector('#vp_bdRightIndex')).attr('disabled', false);
}
});
// on select button event
- $(document).on('click', this.wrapSelector('#vp_bdOnSelect'), function() {
+ $(document).on('click', this.wrapSelector('#vp_bdOn'), function() {
var targetVariable = [ that.state.merge.left.variable, that.state.merge.right.variable ];
that.openColumnPopup(targetVariable, $(that.wrapSelector('#vp_bdOn')), 'Select columns from both dataframe');
});
@@ -221,14 +221,14 @@ define([
if ((colList && colList.length > 0)
|| that.state.merge.right.on && that.state.merge.right.on.length > 0) {
- $(that.wrapSelector('#vp_bdOnSelect')).attr('disabled', true);
+ $(that.wrapSelector('#vp_bdOn')).attr('disabled', true);
} else {
- $(that.wrapSelector('#vp_bdOnSelect')).attr('disabled', false);
+ $(that.wrapSelector('#vp_bdOn')).attr('disabled', false);
}
});
// Left on select button event
- $(document).on('click', this.wrapSelector('#vp_bdLeftOnSelect'), function() {
+ $(document).on('click', this.wrapSelector('#vp_bdLeftOn'), function() {
var targetVariable = [ that.state.merge.left.variable ];
that.openColumnPopup(targetVariable, $(that.wrapSelector('#vp_bdLeftOn')), 'Select columns from left dataframe');
});
@@ -239,9 +239,9 @@ define([
that.state.merge.left.useIndex = useIndex;
if (useIndex || that.state.merge.right.useIndex) {
- $(that.wrapSelector('#vp_bdOnSelect')).attr('disabled', true);
+ $(that.wrapSelector('#vp_bdOn')).attr('disabled', true);
} else {
- $(that.wrapSelector('#vp_bdOnSelect')).attr('disabled', false);
+ $(that.wrapSelector('#vp_bdOn')).attr('disabled', false);
}
});
@@ -252,14 +252,14 @@ define([
if ((colList && colList.length > 0)
|| that.state.merge.left.on && that.state.merge.left.on.length > 0) {
- $(that.wrapSelector('#vp_bdOnSelect')).attr('disabled', true);
+ $(that.wrapSelector('#vp_bdOn')).attr('disabled', true);
} else {
- $(that.wrapSelector('#vp_bdOnSelect')).attr('disabled', false);
+ $(that.wrapSelector('#vp_bdOn')).attr('disabled', false);
}
});
// Right on select button event
- $(document).on('click', this.wrapSelector('#vp_bdRightOnSelect'), function() {
+ $(document).on('click', this.wrapSelector('#vp_bdRightOn'), function() {
var targetVariable = [ that.state.merge.right.variable ];
that.openColumnPopup(targetVariable, $(that.wrapSelector('#vp_bdRightOn')), 'Select columns from right dataframe');
});
@@ -270,9 +270,9 @@ define([
that.state.merge.right.useIndex = useIndex;
if (useIndex || that.state.merge.left.useIndex) {
- $(that.wrapSelector('#vp_bdOnSelect')).attr('disabled', true);
+ $(that.wrapSelector('#vp_bdOn')).attr('disabled', true);
} else {
- $(that.wrapSelector('#vp_bdOnSelect')).attr('disabled', false);
+ $(that.wrapSelector('#vp_bdOn')).attr('disabled', false);
}
});
@@ -574,8 +574,8 @@ define([
$(this.wrapSelector('#vp_bdHow')).val(merge.how);
this._loadSelectorInput(this.wrapSelector('#vp_bdOn'), merge.on);
if (merge.on && merge.on.length > 0) {
- $(this.wrapSelector('#vp_bdLeftOnSelect')).attr('disabled', true);
- $(this.wrapSelector('#vp_bdRightOnSelect')).attr('disabled', true);
+ $(this.wrapSelector('#vp_bdLeftOn')).attr('disabled', true);
+ $(this.wrapSelector('#vp_bdRightOn')).attr('disabled', true);
$(this.wrapSelector('#vp_bdLeftIndex')).attr('disabled', true);
$(this.wrapSelector('#vp_bdRightIndex')).attr('disabled', true);
}
@@ -583,7 +583,7 @@ define([
this._loadSelectorInput(this.wrapSelector('#vp_bdRightOn'), merge.right.on);
if (merge.left.on.length > 0 || merge.right.on.length > 0
|| merge.left.useIndex || merge.right.useIndex) {
- $(this.wrapSelector('#vp_bdOnSelect')).attr('disabled', true);
+ $(this.wrapSelector('#vp_bdOn')).attr('disabled', true);
}
$(this.wrapSelector('#vp_bdLeftIndex')).prop('checked', merge.left.useIndex);
diff --git a/js/m_apps/Frame.js b/js/m_apps/Frame.js
index 87bbb4a7..a6374e8b 100644
--- a/js/m_apps/Frame.js
+++ b/js/m_apps/Frame.js
@@ -630,12 +630,7 @@ define([
// calc - variable 1
content.appendLine('');
content.appendLine('Variable 1 ');
- var dataTypes = ['DataFrame', 'Series', 'nparray', 'list', 'str'];
- var varSelector1 = new VarSelector(dataTypes, 'DataFrame', true, true);
- varSelector1.addBoxClass('vp-inner-popup-var1box mb5');
- varSelector1.addClass('vp-inner-popup-var1');
- content.appendFormatLine('{0}', varSelector1.render());
- content.appendFormatLine(' ', 'vp-inner-popup-var1col');
+ content.appendFormatLine(' ', 'vp-inner-popup-var1col');
content.appendLine(' ');
// calc -operator
content.appendLine('');
@@ -650,11 +645,7 @@ define([
// calc - variable 2
content.appendLine(' ');
content.appendLine('Variable 2 ');
- var varSelector2 = new VarSelector(dataTypes, 'DataFrame', true, true);
- varSelector2.addBoxClass('vp-inner-popup-var2box mb5');
- varSelector2.addClass('vp-inner-popup-var2');
- content.appendFormatLine('{0}', varSelector2.render());
- content.appendFormatLine(' ', 'vp-inner-popup-var2col');
+ content.appendFormatLine(' ', 'vp-inner-popup-var2col');
content.appendLine(' ');
content.appendLine('');
content.appendLine(' '); // end of vp-inner-popup-tab calculation
@@ -802,6 +793,33 @@ define([
// bindEventForAddPage
this.bindEventForPopupPage();
+
+ let that = this;
+
+ // set column list
+ vpKernel.getColumnList(this.state.tempObj).then(function(resultObj) {
+ let { result } = resultObj;
+ var colList = JSON.parse(result);
+ var tag1 = new com_String();
+ var tag2 = new com_String();
+ tag1.appendFormatLine('
', 'vp-inner-popup-var1col');
+ tag2.appendFormatLine('', 'vp-inner-popup-var2col');
+ colList && colList.forEach(col => {
+ tag1.appendFormatLine('{2} '
+ , col.value, col.label, col.label);
+ tag2.appendFormatLine('{2} '
+ , col.value, col.label, col.label);
+ });
+ tag1.appendLine(' ');
+ tag2.appendLine(' ');
+ // replace column list
+ $(that.wrapSelector('.vp-inner-popup-var1col')).replaceWith(function() {
+ return tag1.toString();
+ });
+ $(that.wrapSelector('.vp-inner-popup-var2col')).replaceWith(function() {
+ return tag2.toString();
+ });
+ });
// show popup box
this.openInnerPopup(title);
@@ -824,12 +842,8 @@ define([
content['value'] = $(this.wrapSelector('.vp-inner-popup-input2')).val();
content['valueastext'] = $(this.wrapSelector('.vp-inner-popup-istext2')).prop('checked');
} else if (tab == 'calculation') {
- content['var1type'] = $(this.wrapSelector('.vp-inner-popup-var1box .vp-vs-data-type')).val();
- content['var1'] = $(this.wrapSelector('.vp-inner-popup-var1')).val();
content['var1col'] = $(this.wrapSelector('.vp-inner-popup-var1col')).val();
content['oper'] = $(this.wrapSelector('.vp-inner-popup-oper')).val();
- content['var2type'] = $(this.wrapSelector('.vp-inner-popup-var2box .vp-vs-data-type')).val();
- content['var2'] = $(this.wrapSelector('.vp-inner-popup-var2')).val();
content['var2col'] = $(this.wrapSelector('.vp-inner-popup-var2col')).val();
} else if (tab == 'replace') {
var useregex = $(this.wrapSelector('.vp-inner-popup-use-regex')).prop('checked');
@@ -1052,6 +1066,11 @@ define([
code.appendFormat("{0}.drop_duplicates(subset=[{1}], inplace=True)", tempObj, selectedName);
}
break;
+ case FRAME_EDIT_TYPE.DROP_OUT:
+ if (axis == FRAME_AXIS.COLUMN) {
+ code.appendFormat("{0} = vp_drop_outlier({1}, {2})", tempObj, tempObj, selectedName);
+ }
+ break;
case FRAME_EDIT_TYPE.ONE_HOT_ENCODING:
if (axis == FRAME_AXIS.COLUMN) {
code.appendFormat("{0} = pd.get_dummies(data={1}, columns=[{2}])", tempObj, tempObj, selectedName);
@@ -1082,15 +1101,9 @@ define([
var value = com_util.convertToStr(content.value, content.valueastext);
code.appendFormat("{0}[{1}] = {2}", tempObj, name, value);
} else if (tab == 'calculation') {
- var { var1type, var1, var1col, oper, var2type, var2, var2col } = content;
- var var1code = var1;
- if (var1type == 'DataFrame') {
- var1code += "['" + var1col + "']";
- }
- var var2code = var2;
- if (var2type == 'DataFrame') {
- var2code += "['" + var2col + "']";
- }
+ var { var1col, oper, var2col } = content;
+ var var1code = tempObj + "['" + var1col + "']";
+ var var2code = tempObj + "['" + var2col + "']";
code.appendFormat('{0}[{1}] = {2} {3} {4}', tempObj, name, var1code, oper, var2code);
} else if (tab == 'replace') {
var replaceStr = new com_String();
@@ -1368,6 +1381,8 @@ define([
DROP: 3,
DROP_NA: 4,
DROP_DUP: 5,
+ DROP_OUT: 11,
+
ONE_HOT_ENCODING: 6,
SET_IDX: 7,
RESET_IDX: 8,
diff --git a/js/m_apps/Groupby.js b/js/m_apps/Groupby.js
index cd09f4f5..2de775e9 100644
--- a/js/m_apps/Groupby.js
+++ b/js/m_apps/Groupby.js
@@ -141,7 +141,7 @@ define([
});
// groupby select button event
- $(document).on('click', this.wrapSelector('#vp_gbBySelect'), function() {
+ $(document).on('click', this.wrapSelector('#vp_gbBy'), function() {
that.openColumnSelector($(that.wrapSelector('#vp_gbBy')), 'Select columns to group');
});
@@ -180,7 +180,7 @@ define([
});
// display select button event
- $(document).on('click', this.wrapSelector('#vp_gbDisplaySelect'), function() {
+ $(document).on('click', this.wrapSelector('#vp_gbDisplay'), function() {
that.openColumnSelector($(that.wrapSelector('#vp_gbDisplay')), 'Select columns to display');
});
@@ -268,7 +268,7 @@ define([
});
// edit target columns
- $(document).on('click', this.wrapSelector('.vp-gb-adv-col-selector'), function() {
+ $(document).on('click', this.wrapSelector('.vp-gb-adv-col'), function() {
var includeList = that.state.display;
if (includeList && includeList.length > 0) {
includeList = includeList.map(col => col.code);
@@ -309,7 +309,7 @@ define([
});
// edit columns naming
- $(document).on('click', this.wrapSelector('.vp-gb-adv-naming-selector'), function() {
+ $(document).on('click', this.wrapSelector('.vp-gb-adv-naming'), function() {
var parentDiv = $(this).parent();
var columns = $(parentDiv).find('.vp-gb-adv-col').data('list');
if (columns && columns.length > 0) {
@@ -318,7 +318,7 @@ define([
var method = $(parentDiv).find('.vp-gb-adv-method').val();
if (!method || method == '' || method == "''") {
// set focus on selecting method tag
- $(parentDiv).find('.vp-gb-adv-method-selector').focus();
+ $(parentDiv).find('.vp-gb-adv-method').focus();
return;
}
that.openNamingPopup($(parentDiv).find('.vp-gb-adv-naming'), columns, method);
@@ -341,12 +341,12 @@ define([
$(document).off('change', this.wrapSelector('#vp_gbVariable'));
$(document).off('click', this.wrapSelector('.vp-gb-df-refresh'));
$(document).off('change', this.wrapSelector('#vp_gbBy'));
- $(document).off('click', this.wrapSelector('#vp_gbBySelect'));
+ $(document).off('click', this.wrapSelector('#vp_gbBy'));
$(document).off('change', this.wrapSelector('#vp_gbByGrouper'));
$(document).off('change', this.wrapSelector('#vp_gbByGrouperNumber'));
$(document).off('change', this.wrapSelector('#vp_gbByGrouperPeriod'));
$(document).off('change', this.wrapSelector('#vp_gbDisplay'));
- $(document).off('click', this.wrapSelector('#vp_gbDisplaySelect'));
+ $(document).off('click', this.wrapSelector('#vp_gbDisplay'));
$(document).off('change', this.wrapSelector('#vp_gbMethodSelect'));
$(document).off('change', this.wrapSelector('#vp_gbAdvanced'));
$(document).off('change', this.wrapSelector('#vp_gbAllocateTo'));
@@ -355,11 +355,11 @@ define([
$(document).off('click', this.wrapSelector('#vp_gbAdvAdd'));
$(document).off('change', this.wrapSelector('.vp-gb-adv-col'));
- $(document).off('click', this.wrapSelector('.vp-gb-adv-col-selector'));
+ $(document).off('click', this.wrapSelector('.vp-gb-adv-col'));
$(document).off('change', this.wrapSelector('.vp-gb-adv-method-selector'));
$(document).off('click', this.wrapSelector('.vp-gb-adv-method-return'));
$(document).off('change', this.wrapSelector('.vp-gb-adv-naming'));
- $(document).off('click', this.wrapSelector('.vp-gb-adv-naming-selector'));
+ $(document).off('click', this.wrapSelector('.vp-gb-adv-naming'));
$(document).off('click', this.wrapSelector('.vp-gb-adv-item-delete'));
$(document).off('click.' + this.uuid);
}
@@ -396,9 +396,8 @@ define([
var page = new com_String();
page.appendFormatLine('
', 'vp-gb-adv-item');
// target columns
- page.appendFormatLine(' '
+ page.appendFormatLine(' '
, 'vp-gb-adv-col', 'Column list', 'Apply All columns, if not selected');
- page.appendFormatLine('{2} ', 'vp-gb-adv-col-selector', 'vp-button w50', 'Edit');
// method select
page.appendFormatLine('', 'vp-gb-adv-method-selector');
var defaultMethod = '';
@@ -418,8 +417,7 @@ define([
, '/nbextensions/visualpython/img/arrow_left.svg', 'vp-gb-adv-method-return', 'Return to select method');
page.appendLine('
');
// naming
- page.appendFormatLine('
', 'vp-gb-adv-naming', 'Display name');
- page.appendFormatLine('
{2} ', 'vp-gb-adv-naming-selector', 'vp-button w50', 'Edit');
+ page.appendFormatLine('
', 'vp-gb-adv-naming', 'Display name');
// delete button
page.appendFormatLine('
', 'vp-gb-adv-item-delete', 'vp-cursor', '/nbextensions/visualpython/img/close_small.svg');
page.appendLine('
');
diff --git a/js/m_apps/Markdown.js b/js/m_apps/Markdown.js
index ee5ebcf6..405f64c7 100644
--- a/js/m_apps/Markdown.js
+++ b/js/m_apps/Markdown.js
@@ -209,6 +209,9 @@ define([
marked(text, { renderer: renderer }, function (err, html) {
html = mathjaxutils.replace_math(html, math);
let preview = `
${html}
`;
+ if (html == '') {
+ preview = '';
+ }
that.state.preview = preview;
document.getElementById("vp_markdownPreview").innerHTML = preview;
diff --git a/js/m_apps/PDF.js b/js/m_apps/PDF.js
index a8d43f3a..15f3bd78 100644
--- a/js/m_apps/PDF.js
+++ b/js/m_apps/PDF.js
@@ -38,6 +38,8 @@ nltk.download('punkt')`;
_init() {
super._init();
/** Write codes executed before rendering */
+ this.config.installButton = true;
+ this.config.importButton = true;
this.config.dataview = false;
this.config.size = { width: 500, height: 400 };
@@ -52,22 +54,6 @@ nltk.download('punkt')`;
super._bindEvent();
/** Implement binding events */
let that = this;
- // click install
- $(this.wrapSelector('.vp-pdf-install-btn:not(.disabled)')).on('click', function () {
- com_interface.insertCell('code', PDF_INSTALL1);
- com_interface.insertCell('code', PDF_INSTALL2);
-
- });
-
- // click check installed
- $(this.wrapSelector('.vp-pdf-check-btn')).on('click', function () {
- that.checkInstalled();
- });
-
- // click import
- $(this.wrapSelector('.vp-pdf-import-btn')).on('click', function () {
- com_interface.insertCell('code', PDF_IMPORT);
- });
// click file navigation button
$(this.wrapSelector('#vp_openFileNavigationBtn')).on('click', function() {
@@ -99,6 +85,17 @@ nltk.download('punkt')`;
this.checkInstalled();
}
+ generateInstallCode() {
+ return [
+ PDF_INSTALL1,
+ PDF_INSTALL2
+ ];
+ }
+
+ generateImportCode() {
+ return PDF_IMPORT;
+ }
+
generateCode() {
var code = new com_String();
diff --git a/js/m_apps/Profiling.js b/js/m_apps/Profiling.js
index 7190ab3a..5e82048b 100644
--- a/js/m_apps/Profiling.js
+++ b/js/m_apps/Profiling.js
@@ -39,6 +39,8 @@ define([
_init() {
super._init();
/** Write codes executed before rendering */
+ this.config.installButton = true;
+ this.config.importButton = true;
this.config.codeview = false;
this.config.dataview = false;
this.config.runButton = false;
@@ -51,20 +53,6 @@ define([
super._bindEvent();
/** Implement binding events */
let that = this;
- // click install
- $(this.wrapSelector('.vp-pf-install-btn:not(.disabled)')).on('click', function(event) {
- com_interface.insertCell('code', '!pip install pandas-profiling');
- });
-
- // click check installed
- $(this.wrapSelector('.vp-pf-check-btn')).on('click', function() {
- that.checkInstalled();
- });
-
- // click import
- $(this.wrapSelector('.vp-pf-import-btn')).on('click', function(event) {
- com_interface.insertCell('code', 'from pandas_profiling import ProfileReport');
- });
// refresh df
$(this.wrapSelector('.vp-pf-df-refresh')).on('click', function() {
@@ -152,6 +140,16 @@ define([
this.checkInstalled();
}
+ generateInstallCode() {
+ return [
+ '!pip install pandas-profiling'
+ ];
+ }
+
+ generateImportCode() {
+ return 'from pandas_profiling import ProfileReport';
+ }
+
generateCode() {
return "";
}
diff --git a/js/m_apps/Reshape.js b/js/m_apps/Reshape.js
index 5df039d1..38b4daad 100644
--- a/js/m_apps/Reshape.js
+++ b/js/m_apps/Reshape.js
@@ -62,15 +62,15 @@ define([
$(document).off('click', this.wrapSelector('.vp-rs-df-refresh'));
$(document).off('change', this.wrapSelector('#vp_rsType'));
$(document).off('change', this.wrapSelector('#vp_rsIndex'));
- $(document).off('click', this.wrapSelector('#vp_rsIndexSelect'));
+ $(document).off('click', this.wrapSelector('#vp_rsIndex'));
$(document).off('change', this.wrapSelector('#vp_rsColumns'));
- $(document).off('click', this.wrapSelector('#vp_rsColumnsSelect'));
+ $(document).off('click', this.wrapSelector('#vp_rsColumns'));
$(document).off('change', this.wrapSelector('#vp_rsValues'));
- $(document).off('click', this.wrapSelector('#vp_rsValuesSelect'));
+ $(document).off('click', this.wrapSelector('#vp_rsValues'));
$(document).off('change', this.wrapSelector('#vp_rsIdVars'));
- $(document).off('click', this.wrapSelector('#vp_rsIdVarsSelect'));
+ $(document).off('click', this.wrapSelector('#vp_rsIdVars'));
$(document).off('change', this.wrapSelector('#vp_rsValueVars'));
- $(document).off('click', this.wrapSelector('#vp_rsValueVarsSelect'));
+ $(document).off('click', this.wrapSelector('#vp_rsValueVars'));
$(document).off('change', this.wrapSelector('#vp_rsUserOption'));
$(document).off('change', this.wrapSelector('#vp_rsAllocateTo'));
$(document).off('change', this.wrapSelector('#vp_rsResetIndex'));
@@ -135,7 +135,7 @@ define([
});
// index select button event
- $(document).on('click', this.wrapSelector('#vp_rsIndexSelect'), function() {
+ $(document).on('click', this.wrapSelector('#vp_rsIndex'), function() {
var targetVariable = [ that.state.variable ];
var excludeList = [ ...that.state.pivot.columns, ...that.state.pivot.values ].map(obj => obj.code);
that.openColumnSelector(targetVariable, $(that.wrapSelector('#vp_rsIndex')), 'Select columns', excludeList);
@@ -148,7 +148,7 @@ define([
});
// columns select button event
- $(document).on('click', this.wrapSelector('#vp_rsColumnsSelect'), function() {
+ $(document).on('click', this.wrapSelector('#vp_rsColumns'), function() {
var targetVariable = [ that.state.variable ];
var excludeList = [ ...that.state.pivot.index, ...that.state.pivot.values ].map(obj => obj.code);
that.openColumnSelector(targetVariable, $(that.wrapSelector('#vp_rsColumns')), 'Select columns', excludeList);
@@ -161,7 +161,7 @@ define([
});
// values select button event
- $(document).on('click', this.wrapSelector('#vp_rsValuesSelect'), function() {
+ $(document).on('click', this.wrapSelector('#vp_rsValues'), function() {
var targetVariable = [ that.state.variable ];
var excludeList = [ ...that.state.pivot.index, ...that.state.pivot.columns ].map(obj => obj.code);
that.openColumnSelector(targetVariable, $(that.wrapSelector('#vp_rsValues')), 'Select columns', excludeList);
@@ -174,7 +174,7 @@ define([
});
// id vars select button event
- $(document).on('click', this.wrapSelector('#vp_rsIdVarsSelect'), function() {
+ $(document).on('click', this.wrapSelector('#vp_rsIdVars'), function() {
var targetVariable = [ that.state.variable ];
var excludeList = that.state.melt.valueVars.map(obj => obj.code);
that.openColumnSelector(targetVariable, $(that.wrapSelector('#vp_rsIdVars')), 'Select columns', excludeList);
@@ -187,7 +187,7 @@ define([
});
// value vars select button event
- $(document).on('click', this.wrapSelector('#vp_rsValueVarsSelect'), function() {
+ $(document).on('click', this.wrapSelector('#vp_rsValueVars'), function() {
var targetVariable = [ that.state.variable ];
var excludeList = that.state.melt.idVars.map(obj => obj.code);
that.openColumnSelector(targetVariable, $(that.wrapSelector('#vp_rsValueVars')), 'Select columns', excludeList);
diff --git a/js/m_apps/Subset.js b/js/m_apps/Subset.js
index 5e8e2d12..74ad9cac 100644
--- a/js/m_apps/Subset.js
+++ b/js/m_apps/Subset.js
@@ -75,7 +75,7 @@ define([
...this.state
};
- this._addCodemirror('previewCode', this.wrapSelector('#vp_previewCode'), 'readonly');
+ this._addCodemirror('previewCode', this.wrapSelector('#vp_ssPreviewCode'), 'readonly');
}
render() {
@@ -1331,14 +1331,13 @@ define([
$(document).on('change', this.wrapSelector('.vp-ds-cond-tbl .vp-col-list'), function () {
var thisTag = $(this);
- var varName = $(this).closest('td').find('.vp-cond-var').val();
+ var varName = that.state.pandasObject;
var colName = $(this).find('option:selected').attr('data-code');
var condTag = $(this).closest('td').find('.vp-condition');
- var code = com_util.formatString('_vp_print(_vp_get_column_category({0}, {1}))', varName, colName);
// get result and load column list
- vpKernel.execute(code).then(function (resultObj) {
+ vpKernel.getColumnCategory(varName, colName).then(function (resultObj) {
let { result } = resultObj;
var category = JSON.parse(result);
if (category && category.length > 0) {
diff --git a/js/m_apps/Variable.js b/js/m_apps/Variable.js
index cb2af45d..09c42b80 100644
--- a/js/m_apps/Variable.js
+++ b/js/m_apps/Variable.js
@@ -93,21 +93,23 @@ define([
// HTML rendering
vpKernel.getDataList(types).then(function(resultObj) {
- // var jsonVars = result.replace(/'/gi, `"`);
- // var varList = JSON.parse(jsonVars);
let varListStr = resultObj.result;
var varList = JSON.parse(varListStr);
// add variable list in table
- varList.forEach(varObj => {
+ varList.forEach((varObj, idx) => {
if (types.includes(varObj.varType) && varObj.varName[0] !== '_') {
+ let selected = false;
+ if ((that.state.variable == varObj.varName)) {
+ selected = true;
+ }
var tagTr = document.createElement('tr');
var tagTdName = document.createElement('td');
var tagTdType = document.createElement('td');
$(tagTr).attr({
'data-var-name': varObj.varName,
'data-var-type': varObj.varType,
- 'class': that.state.variable == varObj.varName?'vp-selected':''
+ 'class': selected?'vp-selected':''
});
tagTdName.innerText = varObj.varName;
tagTdType.innerText = varObj.varType;
@@ -151,6 +153,10 @@ define([
}
});
+ if ($(that.wrapSelector('.vp-selected')).length == 0) {
+ $(that.wrapSelector('#vp_var_variableBox tbody tr:nth(0)')).addClass('vp-selected');
+ }
+
// trigger click of selected variable
$(that.wrapSelector('.vp-selected')).click();
});
diff --git a/js/m_ml/Classification.js b/js/m_ml/Classification.js
index 041008c5..b8aa9529 100644
--- a/js/m_ml/Classification.js
+++ b/js/m_ml/Classification.js
@@ -68,11 +68,12 @@ define([
$(that.wrapSelector(`.vp-model-box[data-type="${modelControlType}"]`)).show();
});
- // select model
+ // select model type
$(this.wrapSelector('#modelType')).on('change', function() {
let modelType = $(this).val();
that.state.modelType = modelType;
$(that.wrapSelector('.vp-model-option-box')).html(that.templateForOption(modelType));
+ that.viewOption();
// show install button
if (that.modelConfig[modelType].install != undefined) {
@@ -94,7 +95,7 @@ define([
// change model
$(this.wrapSelector('#model')).on('change', function() {
that.modelEditor.reload();
- })
+ });
}
templateForBody() {
@@ -227,9 +228,67 @@ define([
return optBox.toString();
}
+ viewOption() {
+ // SVC - kernel selection
+ if (this.state.modelType == 'sv-clf') {
+ let kernelType = this.state.kernel;
+ switch (kernelType) {
+ case undefined: // default = rbf
+ case '':
+ case 'rbf': // gamma
+ $(this.wrapSelector('label[for="gamma"]')).show();
+ $(this.wrapSelector('#gamma')).show();
+ // hide others
+ $(this.wrapSelector('label[for="degree"]')).hide();
+ $(this.wrapSelector('#degree')).hide();
+ $(this.wrapSelector('label[for="coef0"]')).hide();
+ $(this.wrapSelector('#coef0')).hide();
+ break;
+ case 'poly': // gamma / degree / coef0
+ $(this.wrapSelector('label[for="gamma"]')).show();
+ $(this.wrapSelector('#gamma')).show();
+ $(this.wrapSelector('label[for="degree"]')).show();
+ $(this.wrapSelector('#degree')).show();
+ $(this.wrapSelector('label[for="coef0"]')).show();
+ $(this.wrapSelector('#coef0')).show();
+ break;
+ case 'sigmoid': // gamma / coef0
+ $(this.wrapSelector('label[for="gamma"]')).show();
+ $(this.wrapSelector('#gamma')).show();
+ $(this.wrapSelector('label[for="coef0"]')).show();
+ $(this.wrapSelector('#coef0')).show();
+ // hide others
+ $(this.wrapSelector('label[for="degree"]')).hide();
+ $(this.wrapSelector('#degree')).hide();
+ break;
+ default:
+ // hide others
+ $(this.wrapSelector('label[for="gamma"]')).hide();
+ $(this.wrapSelector('#gamma')).hide();
+ $(this.wrapSelector('label[for="degree"]')).hide();
+ $(this.wrapSelector('#degree')).hide();
+ $(this.wrapSelector('label[for="coef0"]')).hide();
+ $(this.wrapSelector('#coef0')).hide();
+ break;
+ }
+
+ // Model Creation - SVC kernel selection
+ let that = this;
+ $(this.wrapSelector('#kernel')).off('change');
+ $(this.wrapSelector('#kernel')).change(function() {
+ that.state.kernel = $(this).val();
+ that.viewOption();
+ });
+ }
+
+ }
+
render() {
super.render();
+ // Model Creation - dynamically view options
+ this.viewOption();
+
// Model Editor
this.modelEditor = new ModelEditor(this, "model", "instanceEditor");
}
diff --git a/js/m_ml/Regression.js b/js/m_ml/Regression.js
index 8c09228e..a2c73291 100644
--- a/js/m_ml/Regression.js
+++ b/js/m_ml/Regression.js
@@ -68,11 +68,12 @@ define([
$(that.wrapSelector(`.vp-model-box[data-type="${modelControlType}"]`)).show();
});
- // select model
+ // select model type
$(this.wrapSelector('#modelType')).on('change', function() {
let modelType = $(this).val();
that.state.modelType = modelType;
$(that.wrapSelector('.vp-model-option-box')).html(that.templateForOption(modelType));
+ that.viewOption();
// show install button
if (that.modelConfig[modelType].install != undefined) {
@@ -227,9 +228,67 @@ define([
return optBox.toString();
}
+ viewOption() {
+ // SVR - kernel selection
+ if (this.state.modelType == 'sv-rgs') {
+ let kernelType = this.state.kernel;
+ switch (kernelType) {
+ case undefined: // default = rbf
+ case '':
+ case 'rbf': // gamma
+ $(this.wrapSelector('label[for="gamma"]')).show();
+ $(this.wrapSelector('#gamma')).show();
+ // hide others
+ $(this.wrapSelector('label[for="degree"]')).hide();
+ $(this.wrapSelector('#degree')).hide();
+ $(this.wrapSelector('label[for="coef0"]')).hide();
+ $(this.wrapSelector('#coef0')).hide();
+ break;
+ case 'poly': // gamma / degree / coef0
+ $(this.wrapSelector('label[for="gamma"]')).show();
+ $(this.wrapSelector('#gamma')).show();
+ $(this.wrapSelector('label[for="degree"]')).show();
+ $(this.wrapSelector('#degree')).show();
+ $(this.wrapSelector('label[for="coef0"]')).show();
+ $(this.wrapSelector('#coef0')).show();
+ break;
+ case 'sigmoid': // gamma / coef0
+ $(this.wrapSelector('label[for="gamma"]')).show();
+ $(this.wrapSelector('#gamma')).show();
+ $(this.wrapSelector('label[for="coef0"]')).show();
+ $(this.wrapSelector('#coef0')).show();
+ // hide others
+ $(this.wrapSelector('label[for="degree"]')).hide();
+ $(this.wrapSelector('#degree')).hide();
+ break;
+ default:
+ // hide others
+ $(this.wrapSelector('label[for="gamma"]')).hide();
+ $(this.wrapSelector('#gamma')).hide();
+ $(this.wrapSelector('label[for="degree"]')).hide();
+ $(this.wrapSelector('#degree')).hide();
+ $(this.wrapSelector('label[for="coef0"]')).hide();
+ $(this.wrapSelector('#coef0')).hide();
+ break;
+ }
+
+ // Model Creation - SVC kernel selection
+ let that = this;
+ $(this.wrapSelector('#kernel')).off('change');
+ $(this.wrapSelector('#kernel')).change(function() {
+ that.state.kernel = $(this).val();
+ that.viewOption();
+ });
+ }
+
+ }
+
render() {
super.render();
+ // Model Creation - dynamically view options
+ this.viewOption();
+
// Model Editor
this.modelEditor = new ModelEditor(this, "model", "instanceEditor");
}
diff --git a/js/m_ml/evaluation.js b/js/m_ml/evaluation.js
index d2772e7c..41ab3be5 100644
--- a/js/m_ml/evaluation.js
+++ b/js/m_ml/evaluation.js
@@ -28,20 +28,21 @@ define([
class Evaluation extends PopupComponent {
_init() {
super._init();
+ this.config.importButton = true;
this.config.dataview = false;
this.state = {
modelType: 'rgs',
predictData: 'pred',
targetData: 'y_test',
+ // regression
+ r_squared: true, mae: true, mape: false, rmse: true, scatter_plot: false,
// classification
confusion_matrix: true, report: true,
accuracy: false, precision: false, recall: false, f1_score: false,
- // regression
- coefficient: false, intercept: false, r_squared: true,
- mae: false, mape: false, rmse: true, scatter_plot: false,
+ roc_curve: false, auc: false,
// clustering
- sizeOfClusters: true, silhouetteScore: true,
+ silhouetteScore: true, ari: false, nm: false,
...this.state
}
}
@@ -63,7 +64,39 @@ define([
$(that.wrapSelector('.vp-eval-box')).hide();
$(that.wrapSelector('.vp-eval-'+modelType)).show();
- })
+
+ if (modelType == 'clf') {
+ // Classification - model selection
+ if (that.checkToShowModel() == true) {
+ $(that.wrapSelector('.vp-ev-model')).show();
+ }
+ }
+ });
+
+ // open model selection show
+ $(this.wrapSelector('.vp-eval-check')).on('change', function() {
+ let checked = $(this).prop('checked');
+
+ if (checked) {
+ $(that.wrapSelector('.vp-ev-model')).show();
+ } else {
+ if (that.checkToShowModel() == false) {
+ $(that.wrapSelector('.vp-ev-model')).hide();
+ }
+ }
+ });
+ }
+
+ /**
+ * Check if anything checked available ( > 0)
+ * @returns
+ */
+ checkToShowModel() {
+ let checked = $(this.wrapSelector('.vp-eval-check:checked')).length;
+ if (checked > 0) {
+ return true;
+ }
+ return false;
}
templateForBody() {
@@ -72,7 +105,7 @@ define([
$(page).find('.vp-eval-box').hide();
$(page).find('.vp-eval-'+this.state.modelType).show();
- // varselector TEST:
+ // varselector
let varSelector = new VarSelector2(this.wrapSelector(), ['DataFrame', 'list', 'str']);
varSelector.setComponentID('predictData');
varSelector.addClass('vp-state vp-input');
@@ -85,6 +118,28 @@ define([
varSelector.setValue(this.state.targetData);
$(page).find('#targetData').replaceWith(varSelector.toTagString());
+ // model
+ // set model list
+ let modelOptionTag = new com_String();
+ vpKernel.getModelList('Classification').then(function(resultObj) {
+ let { result } = resultObj;
+ var modelList = JSON.parse(result);
+ modelList && modelList.forEach(model => {
+ let selectFlag = '';
+ if (model.varName == that.state.model) {
+ selectFlag = 'selected';
+ }
+ modelOptionTag.appendFormatLine('
{3} ({4}) ',
+ model.varName, model.varType, selectFlag, model.varName, model.varType);
+ });
+ $(page).find('#model').html(modelOptionTag.toString());
+ $(that.wrapSelector('#model')).html(modelOptionTag.toString());
+
+ if (!that.state.model || that.state.model == '') {
+ that.state.model = $(that.wrapSelector('#model')).val();
+ }
+ });
+
// load state
let that = this;
Object.keys(this.state).forEach(key => {
@@ -114,8 +169,22 @@ define([
}
});
+ if (this.state.modelType == 'clf') {
+ if (this.state.roc_curve == true || this.state.auc == true) {
+ $(page).find('.vp-ev-model').show();
+ } else {
+ $(page).find('.vp-ev-model').hide();
+ }
+ } else {
+ $(page).find('.vp-ev-model').hide();
+ }
+
return page;
}
+
+ generateImportCode() {
+ return 'from sklearn import metrics';
+ }
generateCode() {
let codeCells = [];
@@ -124,6 +193,7 @@ define([
modelType, predictData, targetData,
// classification
confusion_matrix, report, accuracy, precision, recall, f1_score, roc_curve, auc,
+ model,
// regression
coefficient, intercept, r_squared, mae, mape, rmse, scatter_plot,
// clustering
@@ -173,7 +243,7 @@ define([
if (roc_curve) {
code = new com_String();
code.appendLine("# ROC Curve");
- code.appendFormatLine("fpr, tpr, thresholds = roc_curve({0}, svc.decision_function({1}}))", predictData, targetData);
+ code.appendFormatLine("fpr, tpr, thresholds = metrics.roc_curve({0}, {1}.decision_function({2}))", predictData, model, targetData);
code.appendLine("plt.plot(fpr, tpr, label='ROC Curve')");
code.appendLine("plt.xlabel('Sensitivity') ");
code.append("plt.ylabel('Specificity') ")
@@ -182,8 +252,7 @@ define([
if (auc) {
code = new com_String();
code.appendLine("# AUC");
- code.appendFormatLine("fpr, tpr, thresholds = roc_curve({0}, svc.decision_function({1}}))", predictData, targetData);
- code.append("metrics.auc(fpr, tpr)");
+ code.appendFormat("metrics.roc_auc_score({0}, {1}.decision_function({2}))", predictData, model, targetData);
codeCells.push(code.toString());
}
}
@@ -232,7 +301,7 @@ define([
code.appendLine('# Regression plot');
code.appendFormatLine('plt.scatter({0}, {1})', targetData, predictData);
code.appendFormatLine("plt.xlabel('{0}')", targetData);
- code.appendFormatLine("plt.ylabel('{1}')", predictData);
+ code.appendFormatLine("plt.ylabel('{0}')", predictData);
code.append('plt.show()');
codeCells.push(code.toString());
}
diff --git a/js/m_visualize/Seaborn.js b/js/m_visualize/Seaborn.js
index 273c00c6..8135a90c 100644
--- a/js/m_visualize/Seaborn.js
+++ b/js/m_visualize/Seaborn.js
@@ -33,10 +33,19 @@ define([
this.state = {
chartType: 'scatterplot',
+ figWidth: '',
+ figHeight: '',
+ figRow: 0,
+ figColumn: 0,
+ shareX: false,
+ shareY: false,
data: '',
x: '',
y: '',
+ hue: '',
useSampling: true,
+ sampleCount: 30,
+ autoRefresh: true,
...this.state
}
@@ -44,7 +53,8 @@ define([
this.chartTypeList = {
'Relational': [ 'scatterplot', 'lineplot' ],
'Distributions': [ 'histplot', 'kdeplot', 'ecdfplot', 'rugplot' ], // FIXME: ecdf : no module
- 'Categorical': [ 'stripplot', 'swarmplot', 'boxplot', 'violinplot', 'pointplot', 'barplot' ]
+ 'Categorical': [ 'stripplot', 'swarmplot', 'boxplot', 'violinplot', 'pointplot', 'barplot' ],
+ 'ETC': [ ]
}
}
@@ -52,38 +62,55 @@ define([
super._bindEvent();
let that = this;
+
// setting popup
$(this.wrapSelector('#chartSetting')).on('click', function() {
// show popup box
that.openInnerPopup('Chart Setting');
});
+ // check create subplots
+ $(this.wrapSelector('#createSubplots')).on('change', function() {
+ let checked = $(this).prop('checked');
+ // toggle figure option box
+ if (checked) {
+ $(that.wrapSelector('#subplotBox')).show();
+ } else {
+ $(that.wrapSelector('#subplotBox')).hide();
+ }
+ });
+
+ // create subplots
+ $(this.wrapSelector('#createSubplotsBtn')).on('click', function() {
+ // TODO:
+ });
+
// change tab
$(this.wrapSelector('.vp-tab-item')).on('click', function() {
+ let level = $(this).parent().data('level');
let type = $(this).data('type'); // info / element / figure
- $(that.wrapSelector('.vp-tab-item')).removeClass('vp-focus');
+ $(that.wrapSelector(com_util.formatString('.vp-tab-bar.{0} .vp-tab-item', level))).removeClass('vp-focus');
$(this).addClass('vp-focus');
- $(that.wrapSelector('.vp-tab-page')).hide();
+ $(that.wrapSelector(com_util.formatString('.vp-tab-page-box.{0} .vp-tab-page', level))).hide();
$(that.wrapSelector(com_util.formatString('.vp-tab-page[data-type="{0}"]', type))).show();
- })
+ });
// bind column by dataframe
$(document).on('change', this.wrapSelector('#data'), function() {
- com_generator.vp_bindColumnSource(that.wrapSelector(), this, ['x', 'y'], 'select');
+ com_generator.vp_bindColumnSource(that.wrapSelector(), this, ['x', 'y', 'hue'], 'select');
});
- // chart preview FIXME: real-time preview, is it ok? ex/ violinplot ... too much time to load
- $(this.wrapSelector('#previewTest')).on('click', function() {
+ // preview refresh
+ $(this.wrapSelector('#previewRefresh')).on('click', function() {
that.loadPreview();
});
- // $(this.wrapSelector('select')).on('change', function() {
- // that.loadPreview();
- // });
- // $(this.wrapSelector('input')).on('change', function() {
- // that.loadPreview();
- // });
+ $(this.wrapSelector('.vp-state')).on('change', function() {
+ if (that.state.autoRefresh && that.state.data != '') {
+ that.loadPreview();
+ }
+ });
}
@@ -117,6 +144,19 @@ define([
varSelector.setValue(this.state.featureData);
$(page).find('#data').replaceWith(varSelector.toTagString());
+ // preview sample count
+ let sampleCountList = [30, 50, 100, 300, 500, 700, 1000];
+ let sampleCountTag = new com_String();
+ sampleCountList.forEach(cnt => {
+ let selectedFlag = '';
+ if (cnt == that.state.sampleCount) {
+ selectedFlag = 'selected';
+ }
+ sampleCountTag.appendFormatLine('
{2} ',
+ cnt, selectedFlag, cnt);
+ });
+ $(page).find('#sampleCount').html(sampleCountTag.toString());
+
return page;
}
@@ -222,7 +262,7 @@ define([
loadPreview() {
let that = this;
- let code = this.generateCode();
+ let code = this.generateCode(true);
// show variable information on clicking variable
vpKernel.execute(code).then(function(resultObj) {
@@ -277,7 +317,7 @@ define([
return code.toString();
}
- generateCode() {
+ generateCode(preview=false) {
let { chartType, data, x, y, userOption='', allocateTo='', useSampling } = this.state;
let code = new com_String();
let config = this.chartConfig[chartType];
@@ -285,9 +325,13 @@ define([
let chartCode = com_generator.vp_codeGenerator(this, config, this.state, (userOption != ''? ', ' + userOption : ''));
let convertedData = data;
- if (useSampling) {
- // FIXME: sampling code confirm needed, count confirm
- convertedData = data + '.sample(n=30, random_state=0)';
+ if (preview) {
+ // set figure size for preview chart
+ code.appendLine('plt.figure(figsize=(6, 4))');
+ if (useSampling) {
+ // data sampling code for preview
+ convertedData = data + '.sample(n=30, random_state=0)';
+ }
}
// replace pre-defined options