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

@lnsy/charts

v0.1.2

Published

Vanilla HTML Components for generating charts.

Readme

DataRoom Charts

A vanilla JS, CSS and HTML library for creating D3-powered chart components using custom HTML elements. Built on the dataroom-js framework with rspack for bundling.

Installation

Clone the repository:

git clone <your-repo-url>
cd dataroom-charts
npm install

Usage

The main component is <dataroom-chart>, a custom HTML element that renders various chart types using D3.js.

Basic Example

<dataroom-chart type="bar" width="600" height="400">
[
  { "label": "A", "value": 30 },
  { "label": "B", "value": 80 },
  { "label": "C", "value": 45 },
  { "label": "D", "value": 60 }
]
</dataroom-chart>

Chart Types

Bar Chart

  • Type: bar or barchart
  • Orientations: vertical (default), horizontal
  • Data Format: Array of objects with label and value properties
<dataroom-chart type="bar" orientation="horizontal">
[
  { "label": "Category A", "value": 25 },
  { "label": "Category B", "value": 40 },
  { "label": "Category C", "value": 35 }
]
</dataroom-chart>

Scatter Plot

  • Type: scatter or scatterchart
  • Data Format: Array of objects with x, y, optional r (radius), c (category/color)
<dataroom-chart type="scatter" width="500" height="300">
[
  { "x": 1, "y": 10, "r": 5, "c": "Group 1" },
  { "x": 2, "y": 20, "r": 8, "c": "Group 1" },
  { "x": 3, "y": 15, "r": 6, "c": "Group 2" }
]
</dataroom-chart>

Line Graph

  • Type: line, line-graph, or linegraph
  • Data Format: Same as scatter plot
  • Features: Connects points with lines, grouped by category
<dataroom-chart type="line" line-width="3">
[
  { "x": 1, "y": 10, "c": "Series A" },
  { "x": 2, "y": 15, "c": "Series A" },
  { "x": 3, "y": 12, "c": "Series A" },
  { "x": 1, "y": 5, "c": "Series B" },
  { "x": 2, "y": 8, "c": "Series B" },
  { "x": 3, "y": 11, "c": "Series B" }
]
</dataroom-chart>

Donut Chart

  • Type: donut or donutchart
  • Data Format: Array of objects with label and value properties
  • Features: Labels can be disabled with labels="false"
<dataroom-chart type="donut" width="400" height="400">
[
  { "label": "Slice A", "value": 30 },
  { "label": "Slice B", "value": 25 },
  { "label": "Slice C", "value": 45 }
]
</dataroom-chart>

Attributes

| Attribute | Description | Default | Chart Types | |-----------|-------------|---------|-------------| | type | Chart type (bar, scatter, line, donut) | Required | All | | width | Chart width in pixels | 400 | All | | height | Chart height in pixels | 400 | All | | orientation | Bar chart orientation (vertical, horizontal) | vertical | Bar | | monochrome | Enable monochrome mode with patterns | false | All | | color | Override default color | CSS --hi or palette | All | | labels | Show/hide labels | true | Donut | | line-width | Line thickness | 2 | Line | | radius | Point radius | 5 (scatter), 4 (line) | Scatter, Line | | min-radius | Minimum bubble size | 2 | Scatter, Line | | max-radius | Maximum bubble size | 15 | Scatter, Line | | data | JSON data as attribute | Content | All | | src | URL to an external JSON data file | null | All |

Data Formats

Data can be provided to the chart in three ways. If multiple sources are provided, the priority is as follows: data attribute > src attribute > element content.

Via Element Content (Recommended)

<dataroom-chart type="bar">
[
  { "label": "A", "value": 30 },
  { "label": "B", "value": 80 }
]
</dataroom-chart>

Via Data Attribute

<dataroom-chart type="bar" data='[{"label":"A","value":30},{"label":"B","value":80}]'></dataroom-chart>

Via External JSON File (src)

You can load data from an external JSON file by providing a URL to the src attribute.

<dataroom-chart type="bar" src="path/to/your/data.json"></dataroom-chart>

Monochrome Mode

Enable monochrome mode with patterns for print-friendly or accessible charts:

<dataroom-chart type="bar" monochrome="true">
[
  { "label": "A", "value": 30 },
  { "label": "B", "value": 80 }
]
</dataroom-chart>

Monochrome mode uses SVG patterns (diagonal stripes, dots, circles, etc.) instead of colors to differentiate data series.

Styling

The component uses CSS custom properties for theming:

:root {
  --color-1: #440154;
  --color-2: #482878;
  --color-3: #3e4989;
  /* ... up to --color-12 */
  --hi: #fde725; /* Highlight color */
}

Development

Running the Project

npm run start

Starts the development server on port 3000.

Building the Project

npm run build

Creates optimized files in the dist folder.

Build Customization

Create a .env file to customize build output:

OUTPUT_FILE_NAME=dataroom-charts.min.js
PORT=8080