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 🙏

© 2024 – Pkg Stats / Ryan Hefner

barlayer

v0.0.1-beta.2

Published

Custom DeckGL layer of Washington Post visualization of bars.

Downloads

1

Readme

BarLayer

This is a custom DeckGL layer of using bars to represent values using: colour, scale, thickness and rotation angle. These are defined and used in the underlying GL (Graphics Library) via the following methods:

  • getColor, an array of four RGBA values with default [0, 0, 0, 255]
  • getScale, an integer/float with default 1
  • getWidth, an integer/float with default 1
  • getRotationAngle, an integera/float with default 1

For more on proportional symbol maps, you can visit Wikipedia or follow this citation: Brewer, Cynthia, and Andrew J. Campbell. "Beyond graduated circles: varied point symbols for representing quantitative data on maps." Cartographic Perspectives 29 (1998): 6-25.

How to use it

npm i barlayer or yarn add barlayer

Say you have some election data in geojson, like:

{
  ...
 "result": "Lab hold", "first_party": "Lab", "second_party": "Con", "electorate": 50750, "valid_votes": 31598, "invalid_votes": 82, "majority": 10490, "con": 6518, "lab": 17008, "ld": 1072, "geometry": { "type": "Point", "coordinates": [ -3.7047, 51.588501 ] }
  ...
}

You can define a new layer for your DeckGL view as:

    const barlayer = new BarLayer({
      id: 'bar-layer',
      data: data,
      getPosition: d => [d.geometry.coordinates[0],
      d.geometry.coordinates[1], 0],
      getColor: d => getColor(d.properties.first_party.toLowerCase()),
      getScale: d => d.properties.electorate%200,
      getRotationAngle: d => d.properties.result.includes("gain") ? 25 :0 ,
      pickable: true,
      onHover: this._hover, // find out from DeckGL docs
    })

Tests

Some basic unit tests with jest and enzyme. Run: yarn run test

Acknowledgement

This is an output from Turing Geoviuslization Engine work funded by the Alan Turing Institute and carried out at Leeds Institute for Data Analytics led by Dr Nik Lomax and Dr Roger Beecham.

I could not have made sense of the whole JS/GL work done by the DeckGL team if it was not for the help on the Slack channel by Xiaoji Chen.