npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

pagedtablejs

v0.1.7

Published

JavaScript data table for Data Science

Downloads

33

Readme

Getting Started

To use pagedtable.js include its source:

<script type="text/javascript" src="js/pagedtable.js"></script>

Or install from NPM:

npm install pagedtablejs

You can then easily create a table with the JSON from a URL:

<div data-pagedtable data-pagedtable-source="https://mlverse.github.io/pagedtablejs/data/iris.json"></div>
/*display*/
<div data-pagedtable>
  <script data-pagedtable-source type="application/json">[{"Sepal.Length":5.1,"Sepal.Width":3.5,"Petal.Length":1.4,"Petal.Width":0.2,"Species":"setosa"},{"Sepal.Length":4.9,"Sepal.Width":3,"Petal.Length":1.4,"Petal.Width":0.2,"Species":"setosa"},{"Sepal.Length":4.7,"Sepal.Width":3.2,"Petal.Length":1.3,"Petal.Width":0.2,"Species":"setosa"},{"Sepal.Length":4.6,"Sepal.Width":3.1,"Petal.Length":1.5,"Petal.Width":0.2,"Species":"setosa"},{"Sepal.Length":5,"Sepal.Width":3.6,"Petal.Length":1.4,"Petal.Width":0.2,"Species":"setosa"}]</script>
</div>

Or by embedding JSON directly into your HTML as follows:

/*preview*/
<div data-pagedtable>
  <script data-pagedtable-source type="application/json">
    [
      { "name": "Mazda RX4",         "mpg": 21.0 },
      { "name": "Mazda RX4 Wag",     "mpg": 21.0 },
      { "name": "Datsun 710",        "mpg": 22.8 },
      { "name": "Hornet 4 Drive",    "mpg": 21.4 },
      { "name": "Hornet Sportabout", "mpg": 18.7 }
    ]
  </script>
</div>

Notice that the data is specified row-wise, which is the default serialization for tables in JSON.

Paging

Paging is automatically enabled as needed. If there is not enough space to render all rows or all columns, pagedtable.js will add paging for you.

/*preview*/
<div data-pagedtable>
  <script data-pagedtable-source type="application/json">
    [
      { "Column A": 1, "Column B": 1, "Column C": 1, "Column D": 1, "Column E": 1},
      { "Column A": 2, "Column B": 2, "Column C": 2, "Column D": 2, "Column E": 2},
      { "Column A": 3, "Column B": 3, "Column C": 3, "Column D": 3, "Column E": 3},
      { "Column A": 4, "Column B": 4, "Column C": 4, "Column D": 4, "Column E": 4},
      { "Column A": 5, "Column B": 5, "Column C": 5, "Column D": 5, "Column E": 5},
      { "Column A": 6, "Column B": 6, "Column C": 6, "Column D": 6, "Column E": 6}
    ]
  </script>
</div>

You can also customize the range of rows and columns to show by adding options in your data source:

/*preview*/
<div data-pagedtable>
  <script data-pagedtable-source type="application/json">
    {
      "options": {
        "rows": { "min": 2, "max": 4 },
        "columns": { "min": 2, "max": 3 }
      },
      "data": [
        { "Column A": 1, "Column B": 1, "Column C": 1, "Column D": 1, "Column E": 1},
        { "Column A": 2, "Column B": 2, "Column C": 2, "Column D": 2, "Column E": 2},
        { "Column A": 3, "Column B": 3, "Column C": 3, "Column D": 3, "Column E": 3},
        { "Column A": 4, "Column B": 4, "Column C": 4, "Column D": 4, "Column E": 4},
        { "Column A": 5, "Column B": 5, "Column C": 5, "Column D": 5, "Column E": 5},
        { "Column A": 6, "Column B": 6, "Column C": 6, "Column D": 6, "Column E": 6}
      ]
    }
  </script>
</div>

Customizing

Appart from specifying the minimum rows and columns to display, you can also customize the columns with specific labels, alignment and type.

/*preview*/
<div data-pagedtable style="width: 50%; margin: auto;">
  <style>
    .pagedtable {
      font-style: italic;
    }
    .pagedtable .even {
      background-color: rgba(140, 200, 140, 0.1);
    }
  </style>
  <script data-pagedtable-source type="application/json">
    {
      "columns": [
        { "name": "name", "label": "Automobile", "type": "character" },
        { "name": "mpg",  "label": "MPG",        "type": "numeric" }
      ],
      "options": {
        "columns": { "min": 1, "max": 20 },
        "rows":    { "min": 10, "max": 20 },
        "shadowDOM": true
      },
      "data": [
        { "name": "Mazda RX4",         "mpg": 21.0 },
        { "name": "Mazda RX4 Wag",     "mpg": 21.0 },
        { "name": "Datsun 710",        "mpg": 22.8 },
        { "name": "Hornet 4 Drive",    "mpg": 21.4 },
        { "name": "Hornet Sportabout", "mpg": 18.7 }
      ]
    }
  </script>
</div>

Notice that the previous example also makes use of <style> to customize additional styles. Under the hood, a paged table makes use of the Shadow DOM to have consistent styling, to turn this off set shadowDOM to false in the options.

HTML

Inline HTML can be rendered as needed. pagedtable.js will attempt to do some cleaning through DOMPurify, and will then render the html inside the table cell for you if it is valid HTML. By default the HTML will not be rendered, and needs to be enabled.

/*preview*/
<div data-pagedtable>
  <script data-pagedtable-source type="application/json">
    {
      "columns": [
        { "name": "name",       "label": "Automobile", "type": "character" },
        { "name": "mpg",        "label": "MPG",        "type": "numeric" },
        { "name": "car_image",  "label": "Picture",    "type": "image", "html": true }
      ],
      "data": [
        { "name": "Mazda RX4",         "mpg": 21.0, "car_image": "<img src='https://upload.wikimedia.org/wikipedia/commons/5/5b/1974_Mazda_RX4_Coupe_%2824282369814%29.jpg' height=20/>"},
        { "name": "Mazda RX4 Wag",     "mpg": 21.0, "car_image": "<img src='https://upload.wikimedia.org/wikipedia/commons/1/16/Mazda_RX4_Wagon_%281976%2C_127_PS%29.JPG' height=20/>"},
        { "name": "Datsun 710",        "mpg": 22.8, "car_image": "<img src='https://upload.wikimedia.org/wikipedia/commons/9/95/Datsun_710_two-door_orange%2C_front_left.jpg' height=20/>"},
        { "name": "Hornet 4 Drive",    "mpg": 21.4, "car_image": "<img src='https://upload.wikimedia.org/wikipedia/commons/4/46/1970_AMC_Hornet_SST_2-door_green_Kenosha-f.jpg' height=20/>"},
        { "name": "Hornet Sportabout", "mpg": 18.7, "car_image": "<img src='https://upload.wikimedia.org/wikipedia/commons/c/cc/1976_AMC_Hornet_Sportabout.jpg' height=20/>"}
      ]
    }
  </script>
</div>

Programmatic

You can also create a paged table programmatically by creating the PagedTable object on your:

/*preview*/
<div id="pagedtable"></div>
<script type="application/javascript">
  // create a data frame
  var dataframe = []
  for (var idx = 0; idx < 26; idx++) {
    dataframe[idx] = { letter: String.fromCharCode('A'.charCodeAt(0) + idx), number: idx + 1 };
  }

  // create a paged table
  pagedtable.create(dataframe, "pagedtable");
</script>

Loading

You can make use of D3.js and other libraries to load data into pagedtable.js; for instance, using D3s csv() function we can load data as follows:

<div id="pagedtable-d3"></div>
<script type="application/javascript">
  d3.csv("https://cdn.rawgit.com/vlandham/js_data/master/data/cities.csv").then(function(dataframe) {
    (new PagedTable("pagedtable-d3", dataframe)).init();
  });
</script>
/*display*/
<div id="pagedtable-d3"></div>

Frameworks

You can also integrate pagedetable.js with frameworks like Vue.js, React, Svelte and many others. The next example shows how to make use of Vue.js, please make sure that you reference the framework docs to properly integrate and follow best practices.

/*display*/
<iframe src="examples/vue.html" style="height: 460px;"></iframe>