Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazy hypergrid #5

Merged
merged 18 commits into from
Jan 7, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Lazy hypergrid rendering.
  • Loading branch information
texodus committed Jan 3, 2018
commit ea753e908b60163cc1a55459946d6e688124d00d
38 changes: 33 additions & 5 deletions packages/perspective-viewer-hypergrid/src/js/hypergrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ function generateGridProperties(overrides) {

function setPSP(payload) {
if (payload.data.length === 0) {
this.grid.setData({data: []})
return
this.grid.setData({data: []});
return;
};
if (payload.isTree) {
this.grid.renderer.properties.fixedColumnCount = 1;
Expand Down Expand Up @@ -229,8 +229,6 @@ function setPSP(payload) {

function GridUIFixPlugin(grid) {



grid.canvas.resize = function() {
var box = this.size = this.div.getBoundingClientRect();

Expand Down Expand Up @@ -271,6 +269,24 @@ function GridUIFixPlugin(grid) {
this.paintNow();
}

grid.canvas._tickPaint = grid.canvas.tickPaint;
grid.canvas.tickPaint = async function (t) {
let range = this.component.grid.getVisibleRows();
let s = range[1];
let e = range[range.length - 1];
if (range.length > 1 && (this.dirty || this.__cached_start !== s || this.__cached_end !== e)) {
if (this._updating_cache) {
this._updating_cache.cancel();
}
this._updating_cache = this.component.grid._cache_update(s, e);
await this._updating_cache;
this._updateing_cache = undefined;
this.__cached_start = s;
this.__cached_end = e;
}
this.component.grid.canvas._tickPaint(t);
}

grid._getGridCellFromMousePoint = grid.getGridCellFromMousePoint;
grid.getGridCellFromMousePoint = function(mouse) {
if (this.getRowCount() === 0) {
Expand Down Expand Up @@ -618,6 +634,14 @@ function PerspectiveDataModel(grid) {

// Returns the number of rows for this dataset
getRowCount: function () {
// let range = this.grid.getVisibleRows();
// let s = range[1];
// let e = range[range.length - 1];
// if (range.length > 1 && (this.__cached_start !== s || this.__cached_end !== e)) {
// this.__cached_start = s;
// this.__cached_end = e;
// this.grid._cache_update(s, e);
// }
return this.dataSource.data.length;
},

Expand Down Expand Up @@ -925,12 +949,16 @@ async function grid(div, view, hidden) {
div.innerHTML = "";
div.appendChild(this.grid);
}
this.grid.grid._cache_update = async (s, e) => {
json = await fill_page(view, json, hidden, s, e + 1);
this.grid.set_data(json, schema);
}
if (visible_rows.length > 0) {
this.grid.set_data(json, schema);
this.grid.grid.canvas.resize();
this.grid.grid.canvas.resize();
}
await load_incrementally.call(this, view, schema, hidden, json, nrows, 0);
// await load_incrementally.call(this, view, schema, hidden, json, nrows, 0);
}

global.registerPlugin("hypergrid", {
Expand Down