1.0.2 • Published 2 years ago

react-geo-grapher v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

react-geo-grapher is a library that allows you to display quantitative data across sections of a geographic region.

You must have a geojson file that matches the desired region and this file must follow a specific structure.
see this example.

Install

Using npm:

npm install react-geo-grapher

Using yarn:

yarn add react-geo-grapher

For the library to work correctly it is necessary to add the following line to the .env at the root of the project.

SKIP_PREFLIGHT_CHECK=true

BarMap

      // import your geojson file
      import goias from "./goias.json"
      import {BarMap} from  'react-geo-grapher'

      ...

      // Set the properties
      <BarMap
        style={{ width: "400px", background: "#ffffff" }}
        geojson={goias}
        percents={[40, 30, 30]}
        colors={['#040DA6', '#10863C', '#920B8E']}
        scale={5500}
      />

Properties

ParameterTypeDefinition
percentsArray<number>Each array index will correspond to a section in the map, the sum of array values ​​must equal 100, all numbers must be integers.
colorsArray<string>Each index of the array will match the color of a section on the map.
geojsonFeature or FeatureCollection or anyGeojson file.
styleCSSProperties or undefinedCss properties that will be applied to the \ around the map.
scalenumberProperty from ComposableMapProps that scale the geojson on the map.
ComposableMapProps?ComposableMapPropsMore details here
ZoomableGroupProps?ZoomableGroupPropsMore details here

LineMap

      // import your geojson file
      import goias from "./goias.json";
      import {LineMap} from  'react-geo-grapher'
      ...

      // Set the properties
      <LineMap
        style={{ width: "400px", background: "#ffffff" }}
        geojson={goias}
        percents={[40, 30, 30]}
        colors={['#040DA6', '#10863C', '#920B8E']}
        scale={4700}
        scaleFactor={30}
        strokeWidth="15px"
      />

Properties

ParameterTypeDefinition
percentsArray<number>Each array index will correspond to a section in the map, the sum of array values ​​must equal 100, all numbers must be integers.
colorsArray<string>Each index of the array will match the color of a section on the map.
geojsonFeature or FeatureCollection or anyGeojson file.
styleCSSProperties or undefinedCss properties that will be applied to the \ around the map.
scalenumberProperty from ComposableMapProps that scale the geojson on the map.
scaleFactornumbernumber-1 of lines.
strokeWidthstringstroke width of line (The larger, the greater the height of each line).
ComposableMapProps?ComposableMapPropsMore details here
ZoomableGroupProps?ZoomableGroupPropsMore details here

CircMap

      // import your geojson file
      import goias from "./goias.json";
      import {CircMap} from  'react-geo-grapher'
      ...

      // Set the properties
      <CircMap
        style={{ width: "400px", background: "#ffffff" }}
        geojson={goias}
        percents={[40, 30, 30]}
        colors={['#040DA6', '#10863C', '#920B8E']}
        scale={4700}
        spacing={25}
        itemSize={8}
      />

Properties

ParameterTypeDefinition
limitsArray<number>Each array index will correspond to a section in the map, the sum of array values ​​must equal 100, all numbers must be integers.
colorsArray<string>Each index of the array will match the color of a section on the map.
geojsonFeature or FeatureCollection or anyGeojson file.
styleCSSProperties or undefinedCss properties that will be applied to the \ around the map.
scalenumberProperty from ComposableMapProps that scale the geojson on the map.
spacingnumberSpace between circles.
itemSizenumberCircles radius.
ComposableMapProps?ComposableMapPropsMore details here
ZoomableGroupProps?ZoomableGroupPropsMore details here

SquaredMap

      // import your geojson file
      import goias from "./goias.json";
      import {SquaredMap} from  'react-geo-grapher'
      ...

      // Set the properties
      <SquaredMap
        style={{ width: "400px", background: "#ffffff" }}
        geojson={goias}
        percents={[40, 30, 30]}
        colors={['#040DA6', '#10863C', '#920B8E']}
        scale={4700}
        spacing={25}
        itemSize={8}
      />

Properties

ParameterTypeDefinition
percentsArray<number>Each array index will correspond to a section in the map, the sum of array values ​​must equal 100, all numbers must be integers.
colorsArray<string>Each index of the array will match the color of a section on the map.
geojsonFeature or FeatureCollection or anyGeojson file.
styleCSSProperties or undefinedCss properties that will be applied to the \ around the map.
scalenumberProperty from ComposableMapProps that scale the geojson on the map.
spacingnumberSpace between squares.
itemSizenumberWidth and height of squares.
ComposableMapProps?ComposableMapPropsMore details here
ZoomableGroupProps?ZoomableGroupPropsMore details here

Considerations

  • This library uses products from other libraries, such as react-simple-maps and turf.
  • It is not recommended for use in commercial projects as it contains some incompatibility issues with some geojson file structures.