• Stars
    star
    538
  • Rank 82,538 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 9 years ago
  • Updated about 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Build 1MM row tables with native scroll bars by reusing and yielding nodes.

Smart Table Scroll

Build 1MM row tables with native scroll bars by reusing and yielding nodes.

Created by @ChrisPolis, originally as a component of Datacomb

For related projects, see: Clusterize.js and fixed-data-table

Demo

demo

Usage

var table = new SmartTableScroll({

  // DOM element to render to
  el: document.querySelector('#some-table'),
  
  // Array of objects that will be used to build and update each row
  data: [ { row1Data }, { row2Data } ... ],
  
  // Function used to calculate the height of each row
  heightFn: function(rowData) { return rowData.hasPicture ? 20 : 10; },
  
  // Used when first creating dom nodes for each row
  buildRow: function(rowData) {
    var node = document.createElement('div');
      node.classList.add('test-row');
      node.innerHTML =
        "<div class='test-col index'>"+rowData.index+"</div>"+
        "<div class='test-col color'>"+rowData.color+"</div>"+
        "<div class='test-col random'>"+rowData.random+"</div>";
    return node;
  },
 
  // Used to yield an existing row to a new element in `data`
  updateRow: function(rowData, rowEl) {
    rowEl.childNodes[0].textContent = rowData.index;
    rowEl.childNodes[1].textContent = rowData.color;
    rowEl.childNodes[2].textContent = rowData.random;
  },
 
  // (Optional) How many rows to create nodes for
  //  this needs to be > than the max number of rows that can fit on screen (2x this value seems right)
  //  play around, this will have performance implications
  availableNodes: 200,
});

// To update the table, pass in new data to `updateData`
table.updateData([ { updatedRow1Data }, { updatedRow2Data } ... ]);

Include smart-table-scroll.css or add the following to your CSS:

.sts-container {
  overflow-y: scroll;
  position: relative;
  /* scroll container also needs a fixed/defined height */
}
.sts-container .sts-row {
  position: absolute;
}
.sts-container .sts-bottom-anchor {
  position: absolute;
  height: 1px;
  width: 1px;
}

Known limitations

Firefox has an issue with top css property greater than ~18,000,000px(more info); the 1,000,000 row demo works with Firefox, but larger tables may not.

To build and test locally

$ npm install
$ npm run build
$ npm run serve
$ open localhost:5050

More Repositories

1

scrollIt.js

A jQuery plugin that makes it easy to create paginated, feature vertically scrolling pages.
JavaScript
539
star
2

Pagify

Effortlessly create single page web sites with this jQuery plugin.
JavaScript
487
star
3

datacomb

An interactive tool for exploring large, tabular datasets.
JavaScript
334
star
4

convertSTL

A utility for converting STL files between ASCII and binary encoding.
Ruby
74
star
5

hcluster.js

Agglomerative Hierarchical Clustering in JavaScript. (that plays nice with d3.js).
JavaScript
30
star
6

d3-annotate

πŸ“Œ Interactively and programmatically add, edit, move and save SVG chart annotations.
JavaScript
22
star
7

Apples-and-Oranges

An online version of Apples to Apples built with JavaScript.
JavaScript
14
star
8

distance.js

Vector distance and similarity measurements in JavaScript. eg: Euclidean, Manhattan, Chebyshev, angular distance.
JavaScript
9
star
9

canvas-dpi-scaler

Utility to scale <canvas> for Retina and other high resolution screens.
JavaScript
9
star
10

us-town-names-vis

d3.js visualization prototype code used to build: http://www.bytemuse.com/post/us-town-names-canvas-d3/
JavaScript
8
star
11

Rails_Quiz

A quiz generator built with Ruby on Rails
Ruby
5
star
12

project_euler

Solutions to Project Euler written elegantly in Ruby.
Ruby
3
star
13

nba-seasons-vis

Visualization prototype code and phantomJS script used to build http://www.bytemuse.com/post/nba-games-played-win-record-vis/
JavaScript
3
star
14

Node-Users

A simple login system to demonstrate Node.JS and CouchDB
JavaScript
3
star
15

stl-utilities

Command line utility tools for working with STL/3D printing models.
C
2
star
16

zencms

A model oriented CMS for developers, designers and their clients.
Ruby
2
star
17

Simple-Commerce

A simple, lightweight and flexible Ruby on Rails based eCommerce system.
Ruby
2
star
18

shiny-quantmod-boilerplate

Boilerplate for creating finance applications with Shiny and Quantmod.
R
2
star
19

ractive-range-slider

Ractive component for a range slider composed of two native <input type=range> elements.
JavaScript
1
star
20

dotfiles

. files
Shell
1
star
21

angle

ANother Graphing Library written in d3.js and CoffeeScript
CoffeeScript
1
star
22

lets-explore-dataset-1

[Blog post, visualization development] Let's explore a dataset #1: Seasonality in Air Traffic Routes
1
star