From cfbc858f8f60a7ecd0ad42ee91854cb66b117c58 Mon Sep 17 00:00:00 2001 From: Minku Koo Date: Wed, 31 Jan 2024 21:06:17 +0900 Subject: [PATCH 1/2] Fixed #256 : [BUG] Scrolling Issue with iloc in Subset App When iloc is selected in Subset app - Fixes incorrect indexing issue - Resolves scrollbar being fixed downwards, preventing number clicking and scrolling up. --- visualpython/js/m_apps/Subset.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/visualpython/js/m_apps/Subset.js b/visualpython/js/m_apps/Subset.js index 7c7c74c8..4fdbb2c0 100644 --- a/visualpython/js/m_apps/Subset.js +++ b/visualpython/js/m_apps/Subset.js @@ -343,6 +343,9 @@ define([ $(this.wrapSelector('.select-row .vp-ds-select-box.left')).on('scroll', function() { if ($(this).scrollTop() + $(this).innerHeight() >= ($(this)[0].scrollHeight - 2)) { let scrollPos = $(this).scrollTop(); + if (that.state.rowLimit > that.state.rowList.length){ + return; // Prevents scroll from being fixed downwards + } let start = that.state.rowLimit; let end = start + 10; let subsetVariable = com_util.formatString('{0}.iloc[{1}:{2}]', that.state.pandasObject, start, end); @@ -361,9 +364,9 @@ define([ rowList = rowList.map(function (x) { return { ...x, - label: x.location + '', - value: x.location + '', - code: x.location + '', + label: x.label + '', + value: x.value + '', + code: x.code + '', }; }); } From e7565a12701eef53e38d524c8b41ff1bd9e0f2fc Mon Sep 17 00:00:00 2001 From: Minku Koo Date: Fri, 1 Mar 2024 23:32:32 +0900 Subject: [PATCH 2/2] Fixed #258 : Incorrect Behavior of 'Add All' and 'Del All' Buttons in Subset App Ensure Proper Sorting of Items after 'Del All' Operation --- visualpython/js/com/com_Kernel.js | 8 ++++++-- visualpython/js/m_apps/Subset.js | 2 +- visualpython/python/pandasCommand.py | 5 +++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/visualpython/js/com/com_Kernel.js b/visualpython/js/com/com_Kernel.js index 3540d1f0..addb7093 100644 --- a/visualpython/js/com/com_Kernel.js +++ b/visualpython/js/com/com_Kernel.js @@ -610,10 +610,14 @@ define([ * @param {*} dataframe * @returns */ - getRowList(dataframe) { + getRowList(dataframe, start_idx) { var that = this; + if (typeof start_idx === 'undefined') { + start_idx = 0; + } + return new Promise(function(resolve, reject) { - that.execute(com_util.formatString('_vp_print(_vp_get_rows_list({0}))', dataframe)) + that.execute(com_util.formatString('_vp_print(_vp_get_rows_list({0}, {1}))', dataframe, start_idx)) .then(function(resultObj) { resolve(resultObj); }).catch(function(err) { diff --git a/visualpython/js/m_apps/Subset.js b/visualpython/js/m_apps/Subset.js index 4fdbb2c0..41af3ef4 100644 --- a/visualpython/js/m_apps/Subset.js +++ b/visualpython/js/m_apps/Subset.js @@ -349,7 +349,7 @@ define([ let start = that.state.rowLimit; let end = start + 10; let subsetVariable = com_util.formatString('{0}.iloc[{1}:{2}]', that.state.pandasObject, start, end); - vpKernel.getRowList(subsetVariable).then(function (resultObj) { + vpKernel.getRowList(subsetVariable, start).then(function (resultObj) { let { result } = resultObj; var { list:rowList } = JSON.parse(result); rowList = rowList.map(function (x) { diff --git a/visualpython/python/pandasCommand.py b/visualpython/python/pandasCommand.py index aee1338d..4f8301c6 100644 --- a/visualpython/python/pandasCommand.py +++ b/visualpython/python/pandasCommand.py @@ -11,7 +11,7 @@ # from IPython.core.display is deprecated since IPython 7.14 from IPython.display import display -def _vp_get_rows_list(df): +def _vp_get_rows_list(df, start_idx=0): """ Get Rows List with Detail Information """ @@ -19,7 +19,8 @@ def _vp_get_rows_list(df): indexType = str(df.index.dtype) # make dict for rows info for i, r in enumerate(df.index): - rInfo = { 'label': r, 'value': r, 'location': i } + rInfo = { 'label': r, 'value': r, 'location': start_idx + i } + # value if type(r).__name__ == 'str': rInfo['value'] = "'{}'".format(r)