1.0.11 • Published 7 months ago

react-map-dashboard v1.0.11

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

react-map-dashboard

A simple map component for your dashboard.

Demo

react-map-dashboard playground

Usage

npm install --save react-map-dashboard
import { MapComponent } from "react-map-dashboard";

<MapComponent colors={colors} layers={layers} countriesData={countriesData} />;

You can pass arrays of your own colors and value ranges. Each range should correspond to a separate color. For example:

const colors = ["#f2f0f7", "#dadaeb", "#bcbddc"];

const layers = ["0-10", "10-50", "50-100"];

countriesData is an array of objects. Each object should have a "name" property and a "amount" property. Additionally, you can add an additional data object to each object with the data required for your custom tooltip. For example:

countriesData: [
    { country: "CN", amount: 100 },
    { country: "CA", amount: 1000 },
    { country: "FR", amount: 10, data: { some: 'data'} },
  ],

This library uses country-list as a dependency, so you can use it to get proper country codes and create your countriesData.

Custom tooltip

You can use both the standard tooltip and your custom one. To do this, create a component and pass it to customTooltip:

const CustomTooltip = (props) => {
  return (
    <div>
      <p>{props.country}</p>
      <p>{props.some}</p>
    </div>
  );
};

const MapComponent = () => (
  <MapComponent
    colors={colors}
    layers={layers}
    countriesData={countriesData}
    customTooltip={CustomTooltip}
  />
);

License

MIT © krodetsa


1.0.11

7 months ago

1.0.10

7 months ago

1.0.9

7 months ago

1.0.8

7 months ago

1.0.7

7 months ago

1.0.6

7 months ago

1.0.5

7 months ago

1.0.4

7 months ago

1.0.3

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago

0.1.1

7 months ago

0.1.0

7 months ago