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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@hemicycle/vanilla

v0.1.5

Published

Hemicycle svg component for vanilla JS

Downloads

598

Readme

@hemicycle/vanilla

npm version License: MIT Node.js >=18

Framework-free SVG renderer for parliament-style hemicycle seat charts.

@hemicycle/vanilla wraps @hemicycle/core with a lightweight rendering layer that writes directly into an <svg> element — no framework, no bundler magic required. Pass it a config, call render(), and get a fully drawn hemicycle.


Features

  • Direct SVG rendering — writes <path> elements into any SVGSVGElement you provide
  • Three seat shapesarc (default), rect, and circle
  • Per-seat styling — override color, shape, and border radius on individual seats via seatConfig
  • Hide empty seats — optionally omit unoccupied seats for sparse layouts
  • All @hemicycle/core options — full access to rows, radii, aisles, mirroring, and ordering
  • TypeScript-first — fully typed with ESM and CJS dual output

Installation

npm install @hemicycle/vanilla

@hemicycle/core is a peer dependency and is included automatically.
Requires Node.js ≥ 18 and a DOM environment (browser or jsdom).


Quick Start

<svg id="hemicycle"></svg>
import { Hemicycle } from "@hemicycle/vanilla";

const hemicycle = new Hemicycle({
  rows: 7,
  totalSeats: 577,
  innerRadius: 40,
  outerRadius: 95,
  width: 800,
  height: 420,
});

const svg = document.getElementById("hemicycle") as SVGSVGElement;
hemicycle.render(svg);

API

new Hemicycle(config)

Creates a new renderer. Accepts all @hemicycle/core config options plus the following:

| Option | Type | Default | Description | | ---------------- | ------------ | --------- | -------------------------------------------- | | width | number | 800 | SVG width attribute value | | height | number | 400 | SVG height attribute value | | seatConfig | SeatConfig | see below | Default visual style applied to all seats | | hideEmptySeats | boolean | false | Skip rendering seats with no associated data |

SeatConfig

| Option | Type | Default | Description | | -------------- | ----------------------------- | -------- | ------------------------------------------------------------ | | shape | "arc" \| "rect" \| "circle" | "arc" | Seat shape | | color | string | "#ccc" | Fill color | | borderRadius | number | 1.5 | Corner rounding for arc and rect shapes | | radius | number | 2 | Radius for circle shape; radial thickness for arc/rect |


hemicycle.render(svg)

Clears the target <svg> element and renders all seats into it. Also sets viewBox, width, and height attributes automatically.

hemicycle.render(document.querySelector("svg")!);

hemicycle.updateData(data)

Attaches seat data and computes per-seat paths. Each item must identify a seat by idx or by { rowIndex, seatIndex }, and may include a seatConfig to override the default style for that seat.

hemicycle.updateData([
  { idx: 0, party: "Left", seatConfig: { color: "#e63946" } },
  { idx: 1, party: "Center", seatConfig: { color: "#457b9d" } },
]);

hemicycle.render(svg);

Data items without a seatConfig inherit the global config. The seatConfig field is optional — omit it to use the global default.


hemicycle.updateConfig(config)

Applies a partial config update. Call render() again afterward to redraw.


Other accessors

| Method | Returns | | --------------- | -------------------------------------------------------------- | | getSeatData() | ComputedSeatData<T>[] — seat layouts with computed SVG paths | | getViewBox() | string — the computed SVG viewBox value | | getEngine() | The underlying @hemicycle/core Hemicycle instance | | getConfig() | HemicycleConfig |


Examples

Coloring seats by party

const hemicycle = new Hemicycle({
  rows: 7,
  totalSeats: 577,
  seatConfig: { color: "#ddd", shape: "arc" },
});

hemicycle.updateData(
  members.map((m) => ({
    idx: m.seatNumber,
    seatConfig: { color: m.partyColor },
  })),
);

hemicycle.render(document.querySelector("#parliament")!);

Hiding unoccupied seats

const hemicycle = new Hemicycle({
  rows: 5,
  totalSeats: 100,
  hideEmptySeats: true,
});

hemicycle.updateData(occupiedSeats); // Only these will be drawn
hemicycle.render(svg);

Circular seats with custom radius

const hemicycle = new Hemicycle({
  rows: 6,
  totalSeats: 200,
  seatConfig: {
    shape: "circle",
    radius: 2.5,
    color: "#adb5bd",
  },
});

Reactive updates

const hemicycle = new Hemicycle({ rows: 5, totalSeats: 50 });
hemicycle.render(svg);

// On user interaction, update data and re-render:
button.addEventListener("click", () => {
  hemicycle.updateData(newData);
  hemicycle.render(svg); // cleanUp() is called automatically
});

Seat Shapes

| Shape | Description | | -------- | ---------------------------------------------------------------- | | arc | Curved wedge following the concentric arc of the row (default) | | rect | Rectangular seat aligned to the arc midpoint | | circle | Circle centered at the seat's midpoint |


Related


Contributing

Bug reports and pull requests are welcome on GitHub.


Support


Maintainer

Gabriel Vidal[email protected]


License

MIT