Avaiga / taipy-doc

Holds the documentation set for Taipy, not including the code documentation obviously.
https://docs.taipy.io/
Apache License 2.0
15 stars 20 forks source link

Document Choropleth chart #921

Open FlorianJacta opened 10 months ago

FlorianJacta commented 10 months ago

Improve documentation

Add a page for the choropleth map or a section on the current page for maps.

from taipy.gui import Gui 
import pandas as pd

data = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/2010_alcohol_consumption_by_country.csv')

options = {
    "locationmode": 'country names',
    "autocolorscale": True
}

properties = {
    "type": "choropleth",
    "locations": 'location',
    "z": 'alcohol',
    "text": 'location'
}

layout = {"title": "Pure alcohol consumption<br>among adults (age 15+) in 2010"}

md = "<|{data}|chart|properties={properties}|layout={layout}|options={options}|>"

Gui(md).run()

Here is how we contribute to Taipy Doc.

MuhammadHasnain77 commented 10 months ago

Hi, It's my first time on Github can you guide me more about the issue I want to work on it. Thanks

FlorianJacta commented 10 months ago

Sure! I will help you on that @MuhammadHasnain77. The goal of this issue is to add a section to the Taipy Documentation. The Taipy Documentation is, in fact, a Github repo. If you are unfamiliar with Github, you can use Github Desktop.

You must clone this repository: Taipy Doc. This will put all the files on your local machine somewhere.

Then, create a local branch (see ressource), change this file (taipy-doc\docs\manuals\gui\viselements\charts\map.md) that is the one containing the documentation for maps. Look at how this is done in this Markdown file and try to add a section at the end on Choropleth maps, what it is with images and code like the other section of this Markdown file.

When it is done, go back to GitHub Desktop, commit your changes, push it, and create a Pull Request between your branch and the develop branch. Then, we will review the changes and propose suggestions if needed. Ultimately, we will approve the changes and merge your modification to our documentation!

Just so you know, you might have to fork the repo, GitHub Desktop will tell you.

Don't hesitate to come back to me! Contributors are very dear to us!

MuhammadHasnain77 commented 10 months ago

Sure! I will help you on that @MuhammadHasnain77. The goal of this issue is to add a section to the Taipy Documentation. The Taipy Documentation is, in fact, a Github repo. If you are unfamiliar with Github, you can use Github Desktop.

You must clone this repository: Taipy Doc. This will put all the files on your local machine somewhere.

Then, create a local branch (see ressource), change this file (taipy-doc\docs\manuals\gui\viselements\charts\map.md) that is the one containing the documentation for maps. Look at how this is done in this Markdown file and try to add a section at the end on Choropleth maps, what it is with images and code like the other section of this Markdown file.

When it is done, go back to GitHub Desktop, commit your changes, push it, and create a Pull Request between your branch and the develop branch. Then, we will review the changes and propose suggestions if needed. Ultimately, we will approve the changes and merge your modification to our documentation!

Just so you know, you might have to fork the repo, GitHub Desktop will tell you.

Don't hesitate to come back to me! Contributors are very dear to us!

Thank you so much I will try it

FlorianJacta commented 10 months ago

You have a section on the doc about Notebooks here. The port is always running after the first execution so you can either use this documentation, restart the kernel, or change the port.

FlorianJacta commented 8 months ago

@MuhammadHasnain77 Did you make any progress? How can we help you?

FlorianJacta commented 7 months ago

The new release of Taipy is out with 3.1.

It is now possible to have choropleth with this code:

data.csv

from taipy.gui import Gui 
import taipy.gui.builder as tgb

import json
import pandas as pd
import plotly.express as px

# Reload the CSV file to examine its structure
csv_file_path = 'data.csv'
data_csv = pd.read_csv(csv_file_path)

# Reload the GeoJSON file to match it with the CSV data
geojson_path = 'final.geojson'
with open(geojson_path) as f:
    geojson_data = json.load(f)

# Attempting to find a common key by examining the first feature's properties
first_feature_properties = geojson_data['features'][0]['properties']

# Display the properties to find a common key with the CSV data
first_feature_properties

# Aggregate total population data by district in the CSV
district_population = data_csv.groupby('District')['Total population'].sum().reset_index()

# Set up the map

fig = px.choropleth_mapbox(district_population, 
                           geojson=geojson_data, 
                           locations='District', 
                           featureidkey="properties.District", 
                           color='Total population',
                           color_continuous_scale="Viridis",
                           mapbox_style="open-street-map",
                           zoom=5, center = {"lat": 28.3949, "lon": 84.1240},  # Center on Nepal
                           opacity=0.5,
                           labels={'Total population':'Total Population'}
                          )

fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})

fig.show()

with tgb.Page() as page:
    tgb.chart(figure="{fig}", height="800px")

Gui(page).run(title="Frontend Demo", host="0.0.0.0", port=5002)
jrobinAV commented 5 months ago

Hello @MuhammadHasnain77

Any news on the issue? Please let us know if you are still on it. Otherwise we will unassign you to make it available for another contributor.

Thank you for your understanding.

github-actions[bot] commented 4 months ago

This issue has been labelled as "🥶Waiting for contributor" because it has been inactive for more than 14 days. If you would like to continue working on this issue, please add another comment or create a PR that links to this issue. If a PR has already been created which refers to this issue, then you should explicitly mention this issue in the relevant PR. Otherwise, you will be unassigned in 14 days. For more information please refer to the contributing guidelines.