Skip to content

Commit 303c112

Browse files
authored
Merge pull request #257 from Minku-Koo/devops
Fixed #256 : [BUG] Scrolling Issue with iloc in Subset App
2 parents fca3d9b + e7565a1 commit 303c112

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

visualpython/js/com/com_Kernel.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,10 +610,14 @@ define([
610610
* @param {*} dataframe
611611
* @returns
612612
*/
613-
getRowList(dataframe) {
613+
getRowList(dataframe, start_idx) {
614614
var that = this;
615+
if (typeof start_idx === 'undefined') {
616+
start_idx = 0;
617+
}
618+
615619
return new Promise(function(resolve, reject) {
616-
that.execute(com_util.formatString('_vp_print(_vp_get_rows_list({0}))', dataframe))
620+
that.execute(com_util.formatString('_vp_print(_vp_get_rows_list({0}, {1}))', dataframe, start_idx))
617621
.then(function(resultObj) {
618622
resolve(resultObj);
619623
}).catch(function(err) {

visualpython/js/m_apps/Subset.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -343,10 +343,13 @@ define([
343343
$(this.wrapSelector('.select-row .vp-ds-select-box.left')).on('scroll', function() {
344344
if ($(this).scrollTop() + $(this).innerHeight() >= ($(this)[0].scrollHeight - 2)) {
345345
let scrollPos = $(this).scrollTop();
346+
if (that.state.rowLimit > that.state.rowList.length){
347+
return; // Prevents scroll from being fixed downwards
348+
}
346349
let start = that.state.rowLimit;
347350
let end = start + 10;
348351
let subsetVariable = com_util.formatString('{0}.iloc[{1}:{2}]', that.state.pandasObject, start, end);
349-
vpKernel.getRowList(subsetVariable).then(function (resultObj) {
352+
vpKernel.getRowList(subsetVariable, start).then(function (resultObj) {
350353
let { result } = resultObj;
351354
var { list:rowList } = JSON.parse(result);
352355
rowList = rowList.map(function (x) {
@@ -361,9 +364,9 @@ define([
361364
rowList = rowList.map(function (x) {
362365
return {
363366
...x,
364-
label: x.location + '',
365-
value: x.location + '',
366-
code: x.location + '',
367+
label: x.label + '',
368+
value: x.value + '',
369+
code: x.code + '',
367370
};
368371
});
369372
}

visualpython/python/pandasCommand.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@
1111
# from IPython.core.display is deprecated since IPython 7.14
1212
from IPython.display import display
1313

14-
def _vp_get_rows_list(df):
14+
def _vp_get_rows_list(df, start_idx=0):
1515
"""
1616
Get Rows List with Detail Information
1717
"""
1818
rowInfo = { 'name': df.index.name, 'level': df.index.nlevels, 'list': [] }
1919
indexType = str(df.index.dtype)
2020
# make dict for rows info
2121
for i, r in enumerate(df.index):
22-
rInfo = { 'label': r, 'value': r, 'location': i }
22+
rInfo = { 'label': r, 'value': r, 'location': start_idx + i }
23+
2324
# value
2425
if type(r).__name__ == 'str':
2526
rInfo['value'] = "'{}'".format(r)

0 commit comments

Comments
 (0)