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

@dkkoval/react-md-stats-map

v0.1.5

Published

A React component for visualizing data on a map of Moldova by raion.

Downloads

323

Readme

@dkkoval/react-md-stats-map

A React component for visualizing data on a map of Moldova by raion. This package makes it easy to present regional data visually, providing a choropleth map representation of Moldovan raions (regions).

Features

  • Display a map of Moldova with individual raions colored based on provided data.
  • Supports tooltip interactions to display additional information about each raion.
  • Easy integration with responsive container components to make the map adjust to the size of the parent.

Installation

To install the package, use npm or yarn:

npm install @dkkoval/react-md-stats-map

or

yarn add @dkkoval/react-md-stats-map

Usage

Here is an example of how to use the MDMap component in a React application.

Example

import populationJson from './population.json';
import MDMap, { getRaionCode, RaionCode } from '@dkkoval/react-md-stats-map';

// Assuming the json file has title and value name
interface StatsData {
  title: string;
  valueName: string;
  data: {
    [region: RaionCode]: number;
  };
}

// Helper function to convert region names to raion codes
function transformDataKeys(data: Record<string, number>): Record<RaionCode, number> {
  const transformedData: Partial<Record<RaionCode, number>> = {};

  Object.entries(data).forEach(([key, value]) => {
    const code = getRaionCode(key);
    if (code) {
      transformedData[code] = value;
    }
  });

  return transformedData as Record<RaionCode, number>;
}

function App() {
  const { data: rawData, title, valueName }: StatsData = populationJson;

  const data = transformDataKeys(rawData);

  return (
    <div className='App' style={{
      width: '90vw',
      height: '90vh',
      border: '1px solid #eee',
      display: 'flex',
      justifyContent: 'center',
      alignItems: 'center',
      margin: '24px',
    }}>
      <MDMap
        width={800}
        height={500}
        title={title}
        valueName={valueName}
        data={data}
      />
    </div>
  );
}

export default App;

Props

  • width: The width of the map (number).
  • height: The height of the map (number).
  • title: A string to display as the map title.
  • valueName: The unit or type of data being visualized (e.g., "millions people").
  • data: An object representing the values to display for each raion, where the keys are raion codes and values are numerical data.

Raion Codes

The data prop should use raion codenames as keys to identify different regions. The raion codes used are:

| Raion Name | Code | | ------------ | ---- | | Cahul | CA | | Găgăuzia | GA | | Taraclia | TA | | Cantemir | CT | | Basarabeasca | BS | | Leova | LE | | Cimișlia | CM | | Ştefan Vodă | SV | | Bender | BD | | Căușeni | CS | | Hîncești | HI | | Ialoveni | IA | | Nisporeni | NI | | Chișinău | CU | | Anenii Noi | AN | | Criuleni | CR | | Strășeni | ST | | Ungheni | UN | | Dubăsari | DU | | Călărași | CL | | Transnistria | SN | | Fălești | FA | | Orhei | OR | | Glodeni | GL | | Bălți | BA | | Telenești | TE | | Sîngerei | SI | | Rîșcani | RI | | Rezina | RE | | Şoldănești | SD | | Florești | FL | | Drochia | DR | | Edineț | ED | | Briceni | BR | | Soroca | SO | | Dondușeni | DO | | Ocnița | OC |

Helper Functions

  • getRaionCode(name: string): RaionCode | undefined: Converts a string representing the raion name into the corresponding raion code. This function is useful for transforming user-provided or external data to match the required format.

License

This project is licensed under the Apache-2.0 License. See the LICENSE file for details.

Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request if you have any suggestions or improvements.

Contact

Created by Dmytro Koval. You can reach out via GitHub for any questions or feedback.