Skip to main content

react-simple-maps for Dash

Project description

Dash React Simple Maps

Live demo: dash-react-simple-maps.ploomberapp.io

Installation

pip install dash-react-simple-maps

Run demo locally

cd demo
pip install -r requirements.txt
python app.py

Open: http://localhost:8050

Documentation

The demo.py file showcases various examples of using Dash React Simple Maps. Here's a breakdown of each map type:

  1. Basic Map: A simple world map with basic styling.

    map_basic = dash_react_simple_maps.DashReactSimpleMaps(
        id="map-basic",
        geoUrl=geoUrl,
        projection=ProjectionType.GEO_AZIMUTHAL_EQUAL_AREA,
        stroke="#6c757d",
        strokeWidth=1.0,
        fill="#f9f7f3",
    )
    
  2. Styled Map: A map with custom styling for default and hover states.

    map_styled = dash_react_simple_maps.DashReactSimpleMaps(
        id="map-styled",
        geoUrl=geoUrl,
        projection=ProjectionType.GEO_AZIMUTHAL_EQUAL_AREA,
        style=Style(
            default={
                "fill": "#fefae0",
                "stroke": "#283618",
                "strokeWidth": 0.5,
            },
            hover={
                "fill": "#dda15e",
                "stroke": "#606c38",
                "strokeWidth": 0.5,
            },
        ),
    )
    
  3. Map with Annotations: A map featuring text annotations for different continents.

    map_annotations = dash_react_simple_maps.DashReactSimpleMaps(
        id="map-annotations",
        annotations=[
            {
                "coordinates": [-100, 40],
                "dx": -30,
                "dy": -30,
                "text": "North America",
                "textColor": "#5BC748",
            },
            # ... more annotations ...
        ],
        projection=ProjectionType.GEO_AZIMUTHAL_EQUIDISTANT,
        fill="#f9f7f3",
        stroke="#0fa3b1",
        strokeWidth=0.4,
    )
    
  4. Map with Custom Projection Configuration: A map demonstrating custom projection settings.

    map_projection_config = dash_react_simple_maps.DashReactSimpleMaps(
        id="map-projectionconfig",
        geoUrl=geoUrl,
        projection=ProjectionType.GEO_AZIMUTHAL_EQUIDISTANT,
        projectionConfig=ProjectionConfig(
            rotate=[-20, 0, 0],
            center=[10, 10],
            scale=150,
        ),
    )
    
  5. Map with Markers: A map showing various cities with custom markers.

    map_markers = dash_react_simple_maps.DashReactSimpleMaps(
        id="map-markers",
        projection=ProjectionType.GEO_MERCATOR,
        geoUrl=geoUrl,
        markers=[
            {
                "markerOffset": -30,
                "name": "Brasilia",
                "coordinates": [-47.8825, -15.7942],
                "markerColor": "#FF5533",
                "textColor": "#FFFFFF",
                "fontSize": "22px",
                "textStrokeColor": "#FF5533",
                "textStrokeWidth": 0.4,
            },
            # ... more markers ...
        ],
    )
    
  6. Map with Lines: A map displaying lines connecting different locations.

    map_lines = dash_react_simple_maps.DashReactSimpleMaps(
        id="map-lines",
        projection=ProjectionType.GEO_MERCATOR,
        lines=[
            {
                "from": [-99.1332, 19.4326],  # Mexico City coordinates
                "to": [-3.7038, 40.4168],  # Madrid coordinates
                "stroke": "#0077b6",
                "strokeWidth": 2,
                "strokeLinecap": "round",
            },
            # ... more lines ...
        ],
        geoUrl=geoUrl,
    )
    
  7. Map with Color Property: A map that colors regions based on a specific property (population in this case).

    map_colorproperty = dash_react_simple_maps.DashReactSimpleMaps(
        id="map-colorproperty",
        projection=ProjectionType.GEO_MERCATOR,
        geoUrl=geoUrl,
        colorProperty="POP2005",
        colorDomain=[0, 300_000_000],
        colorRange=["#FFF", "#06F"],
    )
    
  8. Demo Map: A comprehensive map combining color property and custom styling.

    map_demo = dash_react_simple_maps.DashReactSimpleMaps(
        id="map-demo",
        projection=ProjectionType.GEO_MERCATOR,
        geoUrl=geoUrl,
        colorProperty="POP2005",
        colorDomain=[0, 300_000_000],
        colorRange=["#FFF", "#06F"],
        style={
            "hover": {
                "fill": "#0047B3",
                "stroke": "#E8F1FF",
                "strokeWidth": 0.5,
            }
        },
    )
    

These examples demonstrate the versatility of Dash React Simple Maps, allowing for various customizations including projections, styling, annotations, markers, lines, and color-based visualizations.

Setup

npm install
pip install -r requirements.txt
pip install -r tests/requirements.txt

Development

npm run build
python demo/app.py

Release

# generate
npm run build
python setup.py sdist bdist_wheel
ls dist

# test artifact
pip install dash dist/dash_react_simple_maps-0.0.1.tar.gz
python demo.py

# upload
pip install twine
twine upload dist/*

# clean up
rm -rf dist

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dash_react_simple_maps-0.0.2.tar.gz (252.8 kB view details)

Uploaded Source

Built Distribution

dash_react_simple_maps-0.0.2-py3-none-any.whl (253.9 kB view details)

Uploaded Python 3

File details

Details for the file dash_react_simple_maps-0.0.2.tar.gz.

File metadata

  • Download URL: dash_react_simple_maps-0.0.2.tar.gz
  • Upload date:
  • Size: 252.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.10

File hashes

Hashes for dash_react_simple_maps-0.0.2.tar.gz
Algorithm Hash digest
SHA256 c56c617ec2cd2bcfbc522ca5ff4dfe43dd9ab79bd4bece57139570ee4af0d4ba
MD5 59fe3e4beea56d85efbee7b74e780e50
BLAKE2b-256 614eb580854c261223c7b7a71c31f0bce5119e8ccba519b915ade5e362c65a9e

See more details on using hashes here.

File details

Details for the file dash_react_simple_maps-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for dash_react_simple_maps-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6c8f361d441ebdc03d574340393d96f737233b728765550b3e941e50f595f81c
MD5 5e770ad7af8c2c2603fb780200d55ef2
BLAKE2b-256 97b07201f05d7031af92dad8b5817c4d15047b26d0b8cb61adff93320f3f6e94

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page