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

@plotdb/layout

v0.0.12

Published

Layout with CSS

Readme

@plotdb/layout

Compute chart layout by HTML/CSS.

Usage

We will need 3 elements:

  • root node: containing layout and render node. should set with pdl-layout class.
  • layout node: provide layout information with div.pdl-cell for g.pdl-cell with the same data-name attr.
  • render node: containing g.pdl-cell element corresponding to pdl-cell in layout node.

A sample DOM structure in Pug:

#my-chart.pdl-layout
  div(data-type="layout")
    .pdl-cell(data-name="yaxis")
    .pdl-cell(data-name="view")
    .pdl-cell
    .pdl-cell(data-name="xaxis")
  div(data-type="render")
    svg
      g.pdl-cell(data-name="yaxis")
      g.pdl-cell(data-name="view"): rect(ld-each="data")
      g
      g.pdl-cell(data-name="xaxis")

then, init with JS:

mylayout = new layout({root: '#my-chart'})
mylayout.on \render, ->
  d3.select('g.pdl-cell[data-name=view]').call ->
    /* get corresponding node and related size (box{x,y,width,height}) information */
    @layout{node, box}
  @get-box('name') # get bounding box with given name
  @get-node('name') # get DOM node with given name
  @get-group('name') # get `g` (group) with given name
mylayout.init -> ... /* initializing ... */

when the layout object is no longer needed, one should destroy it:

mylayout.destroy!

Configuration

  • autoSvg: true if automatically create corresponding svg and g element. default true
    • even with autoSvg enabled, user can still prepare partial svg / g elements. @plotdb/layout will fill the missing parts automatically.
  • watchResize: true if automatically calls update when container resized. default true.
    • by disabling this you will have to manually call update when you want to update layout.
  • round: set true to automatically round dimensions. default true.

API

  • init(cb): initialize layout. optional cb callback function.
    • cb(): a function called before update but after groups are prepared.
      • run with the context of the inited layout object.
      • if it returns a promise, @plotdb/layout waits until it resolves before calling update
  • root(): get root node
  • getNode(name): get layout node by name
  • getNodes: get all layout nodes in an object, hashed by names
  • getGroup(name): get render g by name
  • getGroups: get all render g in an object, hashed by names
  • getBox(name,cached): -> get bounding client rect or node by name.
    • cached: return cached version if true. default false ( computed in realtime )
  • update(opt): update layout. ( update position of all groups )
    • fire rendering event if opt is true. default false.
  • destroy(): destroy function
  • on(n,cb): handle n event with cb callback function.
  • fire(n, ...v): fire n event with parameters in v.

SVG styling

when rendering text manually with SVG, one should be aware of following settings:

  • line-height should be 1em in HTML layout.
  • dominant-baseline should be hanging in SVG text.

License

MIT