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

nhsd-dataviz

v1.1.0

Published

NHS Digital's Data Visualisation Library

Downloads

4

Readme

NHSD Data Visualisation Library

This is the repository for NHSD's data visualisation library.

The purpose of this library is create accessible data visualisations for web with HTML/SVG, JPG & PNG fallbacks where JavaScript isn't avaliable.


Getting Started

Download the latest release

To you can download the latest releases on the release page.

Build from source

Alternatively you may clone and build your own distribution:

git clone https://github.com/NHS-digital-website/nhsd-dataviz.git
npm install
npm run build

Usage

The following code snippet demonstrates loading the data visualisation library and creating a basic chart:

<html>
    <head>
      <script src="nhsd-dataviz.min.js"></script>
    </head>
    <body>
      <div id="viz"></div>
      <script>
      nhsdviz.chart('#viz', {
        "data": {
            "date": "2022",
            "percent": 18,
            "subject": "adults",
            "description": "had a possible eating disorder",
            "change": {
                "percent": -3,
                "date": "2021"
            }
        }
      });
      </script>
    </body>
</html>

API

Create a chart

nhsdviz.chart(selector, options)

# Options object

| Property | Value | Description | |-------------------|------------------------------------------------------|------------------------------------------| | vizType | "pie" | "doughnut" | "icon" | "stat" | "column" | Chart type (default: pie) | | title | String | Chart title text | | introText | String | Chart introductory text | | data | Data object | Chart data | | source | { text: String, href: String } | Source text | | palette | String | Chart palette | | icon | String (icon name) | Chart icon | | desktopViewport | number (px) | Desktop viewport (default: 1024) |

# Data object

| Property | Value | Description | |--------------|-------------------------------------------------|--------------------------------------| | description | String | Chart description | | subject | String | Data subject | | change | { percent: number, from: number, date: string } | Chart change text | | yAxis | { title: string, start: number, end: number } | yAxis options (column) | | xAxis | { title: string } | xAxis options (column) | | percent | number | Chart percent value (pie & doughnut) | | ratio | { numerator: number, denominator: number } | Chart ratio value (icon) | | quantity | number | Chart quantity value (stat) | | series | { name: string, value: [number] } | Chart series data (column) |

# Supported icons

If building from source icons should be placed in the assets/icons/ directory, these icons can then be referenced by their file names.

If using the distribution library the following icons are avaliable:

  • arrow-down
  • arrow-up
  • calendar
  • invite
  • person
  • tooth
  • wine-glass

Examples

Pie Chart

https://jsfiddle.net/LEJA3/cq8rbs12/

Doughnut Chart

https://jsfiddle.net/LEJA3/f4o6v2xh/

Icon Chart

https://jsfiddle.net/LEJA3/kroLbf4z/

Statistics Chart

https://jsfiddle.net/LEJA3/rov9weby/

Column Chart

https://jsfiddle.net/LEJA3/fqtphz7o/


Colour palette

nhsdviz.createPalette(name, palette)

# Palette object

| Property | Value | Description | |--------------|-------------------------------------------------|--------------------------------------| | primary | String (Hex colour code) | Primary chart colour | | secondary | String (Hex colour code) | Secondary chart colour | | background | String (Hex colour code) | Background chart colour | | text | String (Hex colour code) | Main text colour | | text2 | String (Hex colour code) | Secondary text colour |

Example

https://jsfiddle.net/LEJA3/k2tL0pcq/