Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mapbox density charts #316

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
99 changes: 99 additions & 0 deletions docs/manuals/gui/viselements/charts/mapbox-density.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
## Mapbox density charts

This type of chart creates maps where density can be displayed.


### Basic Mapbox Density Chart - Air Quality Index

In this example, we will visualize the air quality index at 3 locations on map. Bigger circle will have worse air quality.

```py
data = {
"lon": [10, 20, 30],
"lat": [15, 25, 35],
"air_index": [7, 20, 10]
}

layout = {
"mapbox": {
"style": "open-street-map"
}
}
```
!!! example "Page content"

=== "Markdown"

```
<|{data}|chart|lon=lon|lat=lat|z=air_index|type=densitymapbox|layout={layout}|>
```

=== "HTML"

```html
<taipy:chart type="densitymapbox" lon="lon" lat="lat" z="air_index" layout="layout">{data}</taipy:chart>
```

<figure>
<img src="mapbox-air-index-dark.png" class="visible-dark" />
<img src="mapbox-air-index.png" class="visible-light" />
<figcaption>Air Quality Index</figcaption>
</figure>

### World Map with Earthquake Magnitude


```py
df = pandas.read_csv(
'https://raw.githubusercontent.com/plotly/datasets/master/earthquakes-23k.csv')

opts = {
"coloraxis": 'coloraxis',
"hoverinfo": 'skip',
"radius": 5
}

layout = {
'mapbox': {
'style': 'stamen-terrain'
},
"coloraxis": {
"colorscale": "Viridis"
},
"title": {
"text": "Earthquake Magnitude"
}
}
```
!!! example "Page content"

=== "Markdown"

```
<|{df}|chart|type=densitymapbox|lat=Latitude|lon=Longitude|z=Magnitude|options={opts}|layout={layout}|>
```

=== "HTML"

```html
<taipy:chart type="densitymapbox" lat="Latitude" lon="Longitude" z="Magnitude" options="opts" layout="layout">{df}</taipy:chart>
```

<figure>
<img src="mapbox-earthquake-magnitude-dark.png" class="visible-dark" />
<img src="mapbox-earthquake-magnitude.png" class="visible-light" />
<figcaption>World Map with Earthquake Magnitude</figcaption>
</figure>

Explanation of parameters and options relevant to Mapbox density charts can be found [here](https://plotly.com/javascript/reference/densitymapbox/). Full details for the Taipy Chart control can be found in the Chart Control section of the [Taipy GUI User Manual](https://docs.taipy.io/en/latest/manuals/gui/viselements/chart/)

### Key parameters
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move key parameters to the top below the chart description

| Parameter | Value Options | Location |
| --------------- | ------------------------- | ------------------ |
| type | "densitymapbox" | Control definition |
| lon | Column name for longitudes | Control definition |
| lat | Column name for latitudes | Control definition |
| z | Column name for density | Control definition |
| mapbox | Dictionary of parameters for maps (style). [More details](https://plotly.com/javascript/mapbox-layers/) | Layout |
| radius | int | Options |
| coloraxis | Dictionary (colorscale) | Layout+Options |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.