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

generator-politico-graphics

v2.0.2

Published

Generator for developing graphic modules at POLITICO.

Downloads

23

Readme

POLITICO

generator-politico-graphics npm

A Yeoman generator that scaffolds a development environment for building reusable graphic modules.

Why this?

Building data visualizations is expensive, especially for small teams balancing graphics with other development work. At POLITICO, we want to build our charts using patterns that promote reusability and that make them easy to integrate in multiple contexts.

This framework builds on the reusable chart pattern proposed by Mike Bostock in "Toward Reusable Charts," adding to it a few conventions borrowed from reactive programming and modern JS modules. It helps us create chart modules that have simple, declarative APIs and can be easily configured for different uses.

That's the theory. In practice, this framework helps us separate the concerns of dataviz development from other client-side work. We've used it as a shortcut to build dozens of complex data visualization components and reusable chart modules over several years.

Features

  • Scaffolds a modern JavaScript development environment.
  • Includes a base chart component class with useful methods and some example code you can easily rework.
  • Includes a demo of your chart module, used in a React app.
  • Builds a minified, self-executing (IIFE) version of your chart script, which can be included directly in a client.
  • Builds an ECMAScript module version of your script, which can be imported into other build environments.
  • Builds your chart's demo page to a directory for hosting on GitHub pages.
  • Includes POLITICO's ESLint config for keeping your code squeaky clean.

How to use it

What you'll need installed

Make sure you have node, the yarn package manager, yeoman and this generator installed:

$ npm install -g yarn yo generator-politico-graphics

This generator can also create a GitHub repo for you while it's building out your development environment. Export an environment variable with a Github personal access token to GITHUB_TOKEN. The generator will then ask whether you'd like to create a repo with each new build.

Starting a new graphic module

Create a fresh directory for your project and move into it in a terminal window.

$ mkdir my-new-graphic
$ cd my-new-graphic

Now run the generator and answer the questions it asks to build your dev environment.

$ yo politico-graphics

Developing your graphic module

Start the development server.

$ yarn start

The generator includes a basic example of a reusable chart module in src/js/lib/Chart.js. Start there to build your chart.

The README included when you run the generator includes many tips for using this reusable pattern. Read it!

Publishing your graphic module

Once you're ready to publish your module, run:

$ yarn build

From here you can commit your code to GitHub and host the preview page using GitHub pages or publish your module to NPM.