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

svelte-hemicycle

v2.1.0

Published

[![NPM](https://img.shields.io/npm/v/svelte-hemicycle.svg)](https://www.npmjs.com/package/svelte-hemicycle)

Downloads

10

Readme

Svelte Hemicycle

NPM

A data visualisation for the South African elections as a Svelte component. It accepts data as a JSON property from the IEC's NPE Seat Calculation Results API and renders a hemicycle chart.

Hemicycle

Demo

See the hemicycle with South African national elections data here

Installation

npm install svelte-hemicycle

Usage

<script>
  import Hemicycle from 'svelte-hemicycle';
  const data = [
      {
          "id": 1,
          "text": "UDFMP",
          "count": 160,
          "color": "#FF0000"
      },
      {
          "id": 2,
          "text": "PDMF",
          "count": 150,
          "color": "#00FF00"
      },
      {
          "id": 3,
          "text": "DA",
          "count": 40,
          "color": "#0000FF"
      },
      {
          "id": 4,
          "text": "PDP",
          "count": 30,
          "color": "#FFFF00"
      },
      {
          "id": 5,
          "text": "APC",
          "count": 20,
          "color": "#00FFFF"
      }
  ]
  const total_seats = 400;
  const rows= 12;
</script>

<Hemicycle {data} {total_seats} {rows} />

API

data

The data to display on the hemicycle. This is an array of objects, each representing a party or group of seats.

Required.

data = [{
    "id": 1, // Unique identifier
    "text": "UDFMP (60 seats)", // Text to display on the hemicycle
    "count": 60, // Number of seats
    "color": "#FF0000" // Colour of the hemicycle segment
}]

total_seats

The total number of seats in the legislature. This can be greater than the total number of seats in the data.

Required.

total_seats = 400;

r

The radius of the hemicycle.

Default: 300

r = 300;

rows

The number of rows of seats to display.

Default: 12

rows = 12;

dotsize

The size of the dots representing seats.

Default: 5

arc

The angle of the hemicycle, in degrees.

Default: 180 Minimum: 10 Maximum: 360

padding

The padding between the hemicycle and the edge of the SVG.

padding = 30;
padding = [30, 30]; // top, bottom
padding = [30, 30, 30, 30]; // top, right, bottom, left

color

The colour of the text and optional markings.

Default: "white"

font_size

The font size of the text.

Default: 12

text_position

The position of the text.

Defaults to center.

text_position = {
    x: 0,
    y: 0
}

display

An array of strings representing what to display on the hemicycle.

Defaults to ["points", "text"]

"points" - Display the dots of seats "text" - Display the text on mouseover and click "arc" - Display the arcs of the hemicycle "numbers" - Display the seats in order "voronoi" - Display the voronoi diagram "referencePoints" - Display some reference points

display = ["points", "text"]; // Default
display = ["points", "text", "arc", "numbers", "voronoi", "referencePoints"]; // All

shape

Choose between circle and hexagon.

Default: "circle"

shape = "circle";
shape = "hexagon";

stroke

The colour of the stroke around the shapes (Currently hexagon only).

default: "#444444"

stroke = "white";

display_width and display_height

The width and height of the SVG.

Default: 600w x 300h

Tip: For 180 degree arcs, you might want to set the height as half the width. For acute or obtuse angles, you might want to tend towards square.

display_width = 600;
display_height = 300;

License

MIT

Copyright 2024 Jason Norwood-Young

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.