Skip to main content

CleverMaps Marimo Widget - A widget for embedding CleverMaps visualizations in Marimo notebooks.

Project description

CleverMaps Jupyter Widget

A Jupyter widget for embedding and interacting with CleverMaps visualizations in Jupyter notebooks.

Installation

You can install the package using pip:

pip install clevermaps-jupyter-widget

Requirements

  • Python >= 3.9
  • Jupyter notebook or JupyterLab
  • anywidget

Usage

Basic Usage

from cm_jupyter_widget.widget import CleverMapsWidget

# Create a widget with a view URL
widget = CleverMapsWidget(view_url="https://your-view-url")

# Display the widget
widget

Advanced Usage with Options

# Create a widget with custom options
widget = CleverMapsWidget(
    view_url="https://your-view-url",
    options='''{
        "componentSettings": {
            "infoBox": {
                "defaultExpanded": false
            },
            "tools": {
                "search": false
            }
        },
        "theme": {
            "colorPrimary": "#0055ff"
        },
        "interactivity": {
            "afterClick": false
        },
        "fullScreenButton": {
            "enabled": false
        },
        "studioLinkButton": {
            "enabled": false
        }
    }'''
)

API Reference

Widget Properties

  • view_url (required): The URL of the CleverMaps view to display
  • base_url (optional): The base URL for CleverMaps API (defaults to 'https://secure.clevermaps.io/')
  • options (optional): A JSON string containing configuration options for the widget

Methods

toggle_fit_all()

Fits all features in the current view.

add_filter(definition_id: str, values: Dict[str, Any], instance_id: str)

Adds a new filter to the view.

Parameters:

  • definition_id: The ID of the filter definition
  • values: Filter values (format depends on filter type)
  • instance_id: The instance ID of the filter

Filter value formats:

  • MultiSelect: {"values": ["Male", 1, null]}
  • SingleSelect: {"value": "selected_value"} or {"value": null}
  • Feature: {"values": ["feature1", 1]} or {"values": null}
  • Histogram: {"values": [1, 10], "nullFiltered": true} or {"values": [null, null]}
  • Date: {"startDate": {"value": "2023-01-01"}, "endDate": {"value": "2023-12-31"}}
  • Indicator: {"values": [min, max], "granularity": "year"}

set_filter(instance_id: str, value)

Sets the value of an existing filter.

Parameters:

  • instance_id: The instance ID of the filter to set
  • value: The new filter value

remove_filter(instance_id: str)

Removes a filter from the view.

Parameters:

  • instance_id: The instance ID of the filter to remove

reset_filter(instance_id: str)

Resets a filter to its default state.

Parameters:

  • instance_id: The instance ID of the filter to reset

set_state(view_url: str)

Loads a new view URL.

Parameters:

  • view_url: The URL of the view to load

open_bookmark_modal()

Opens the bookmark modal dialog.

open_export_modal()

Opens the export modal dialog.

Examples

Check out the example notebook in the repository:

  • sdk-test.ipynb: Advanced usage and testing examples

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Karel Psota (karel.psota@clevermaps.io)

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

cm_jupyter_widget-0.2.0.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cm_jupyter_widget-0.2.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file cm_jupyter_widget-0.2.0.tar.gz.

File metadata

  • Download URL: cm_jupyter_widget-0.2.0.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.3

File hashes

Hashes for cm_jupyter_widget-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d58ee2f0f4b897b970ac55219596a14980f9928e0cb0d6af6b4823b24adc1400
MD5 311e536cfd94fa4ab717baf76c1144a1
BLAKE2b-256 f973e4364def1427c611b8dc2fc98c8ac013014480be325e730d45dec985a7b1

See more details on using hashes here.

File details

Details for the file cm_jupyter_widget-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cm_jupyter_widget-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5c35012f8c5f244e8cca578c72bb8308ea5f4f7b54e9e6aa8b26f38490d477c7
MD5 93bf83b64644c6220085a41b27cd5d5d
BLAKE2b-256 d9056b60a6419adf9c42f5058b92665d5e635e626d4dc500246efb2dea283487

See more details on using hashes here.

Supported by

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