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

component-simple-graph

v0.0.2

Published

A foolproof web component for non-interactive charts and graphs

Downloads

15

Readme

component-simple-graph

A custom element for creating simple, static line and bar charts from CSV data. The first column in the data will be used to generate the x-axis, while remaining columns will be used for data series. For example, the following code would create a chart with five series in it::

<simple-graph mode="bar">
  benchmark,Shell,Perl,Python,Ruby_1.8,Ruby_1.9
  sort,2.14,0.78,0.83,1.47,0.87
  sort 10x,15.81,6.91,4.80,22.21,9.44
  sort 20x,35.25,18.42,16.80,601.43,29.80
  sort 50x,112.12,600.34,126.91,600.61,80.12
  md5,26.98,0.88,0.94,0.47,0.57
  text replace,3.00,1.33,4.38,3.02,2.77
  http get,6.99,3.73,0.89,1.73,1.99
</simple-graph>

You can also feed Google data into a graph from a spreadsheet by setting the sheet attribute on the element with the Google sheet ID. We do not recommend using this for long-term support, given that the Sheets API is not guaranteed to be stable, but it can be useful during breaking news situations::

<simple-graph sheet="1U_gi_kTy6oHiEPpcHsfyKNwwOTJxS8qdg1oQB9jHzJU">
</simple-graph>

The element will automatically scale the graph to fit the data, including negative numbers, although datasets with entirely positive values will be graphed against 0 (as is right and proper).

Config options

simple-graph may be configured via a number of attributes on the element.

  • mode - (default: "line") If set to "bar", will use a grouped bar chart instead of a line chart.
  • colors - Used to set the palette for the graph series. If there aren't enough colors provided, the default Seattle Times palette will be used to fill them in.
  • sheet - Set this to a Google Sheets ID to load data from that sheet over AJAX. It will only use the first sheet in the workbook.
  • nokey - Turns off visible keys. Keys are also disabled if there's only one series in the data.

Notes

In an attempt to fit your site's CSS, the graph will load computed styles from the DOM and use those for its labels, although it does include some defaults (namely, font-size, margin, and max-width) scoped to the simple-graph selector. These can be overridden with any more-specific selector (a class is a good way to go).

simple-graph was built using the Seattle Times web component template <https://github.com/seattletimes/component-template>__. It was completed with the support of a Knight-Mozilla code convening at the 2015 Write the Docs conference in Portland, OR.