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

react-windrose-chart

v1.0.0

Published

React Wind Rose Chart Component (D3js implemented SVG rendering)

Downloads

320

Readme

Windrose Chart Component

Unit Test Node.js Package CodeQL codecov npm npm version GitHub version License: MIT

Storybook

Features

react-windrose-chart

  • D3js (Javascript library for manipulating documents based on data) implemented SVG rendering
  • Inspired from ssmaroju's Wind Rose Plot

Installation

npm i react-windrose-chart

Usage

import React from "react";
import { Chart } from "react-windrose-chart";

const data = {
  chartData: [
    {
      angle: "N  ",
      "0-1": 0.5,
      /* ... */
      "6-7": 0.2,
      "7+": 0.1,
      total: 4.9,
    } /* ... */,
  ],
  columns: [
    "angle",
    "0-1",
    /* ... */
    "6-7",
    "7+",
  ],
};

const App = () => (
  <div>
    <Chart
      chartData={data.chartData}
      columns={data.columns}
      responsive
      legendGap={10}
    />
  </div>
);

Props

| Prop | Type | Required | Description | Default | | :------------: | :-------------------: | :--------: | :-------------------------------------------- | :------ | | chartData | ChartData[] | Required | Wind Rose Chart data | | | columns | (keyof ChartData)[] | Required | Wind Rose Chart header string array | | | width | number | | container width, default value: 500 | 500 | | height | number | | container height, default value: 500 | 500 | | responsive | boolean | | responsive default, value: false | false | | legendGap | number | | width gap size in px between chart and legend | 10 |

Notice, when responsive is true, width and height would be ignored. chart container's aspect ratio is 1/1 and size width fit as 100% of parent container

chartData Object array

check sample data

| Key | Type | Required | Description | Default | | :-------: | :------: | :--------: | :---------------------------------------------------------------------------------------------------------------- | :------ | | 0-1 | number | Required | Frequency of 0-1 m/sec | | | 1-2 | number | Required | Frequency of 1-2 m/sec | | | 2-3 | number | Required | Frequency of 2-3 m/sec | | | 3-4 | number | Required | Frequency of 3-4 m/sec | | | 4-5 | number | Required | Frequency of 4-5 m/sec | | | 5-6 | number | Required | Frequency of 5-6 m/sec | | | 6-7 | number | Required | Frequency of 6-7 m/sec | | | 7+ | number | Required | Frequency of 7+ m/sec | | | angle | string | Required | Wind direction N, NNE, NE, ENE, E, ESE, SE, SSE, S, SSW, SW, WSW, W, WNW, NW, NNW | | | total | number | Required | Sum of frequencies of this direction | |

Data utils

  • Wind Rose data can be converted by Wind direction(degree) and wind speed data: {direction: number[], speed: number[]} to data: ChartData[]
import { caculateWindRose } from "@eunchurn/react-windrose";

const data = {
  direction: [270, 256, 240,...],
  speed: [ 1.02, 0.85, 0.98,...]
}

const windRoseData = calculateWindRose(data);
// Return 
// [
//   {
//     angle: 'N',
//     '0-1': 0,
//     '1-2': 0,
//     '2-3': 0,
//     '3-4': 0,
//     '4-5': 0,
//     '5-6': 0,
//     '6-7': 0,
//     '7+': 0,
//     total: 0
//   },
//   {
//     angle: 'NNE',
//     '0-1': 0,
//     '1-2': 0,
//     '2-3': 0,
//     '3-4': 0,
//     '4-5': 0,
//     '5-6': 0,
//     '6-7': 0,
//     '7+': 0,
//     total: 0
//   },
//   ...
// ]
  • Classifying direction function only is as:
import { classifyDir } from "@eunchurn/react-windrose";

const directionCharacter = classifyDir(270);
// Return : 'W'

Real-Time

Real-Time chart data from Anemometer

realtime-chart

License

MIT