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

Document Choropleth chart #921

Open
FlorianJacta opened this issue Dec 1, 2023 · 8 comments
Open

Document Choropleth chart #921

FlorianJacta opened this issue Dec 1, 2023 · 8 comments
Labels
📄 Documentation Internal or public documentation good first issue New-contributor friendly 🟩 Priority: Low Low priority and doesn't need to be rushed

Comments

@FlorianJacta
Copy link
Member

FlorianJacta commented Dec 1, 2023

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.

@FlorianJacta FlorianJacta added 📄 Documentation Internal or public documentation good first issue New-contributor friendly 🟩 Priority: Low Low priority and doesn't need to be rushed labels Dec 1, 2023
@MuhammadHasnain77
Copy link

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

@FlorianJacta
Copy link
Member Author

FlorianJacta commented Dec 4, 2023

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
Copy link

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
Copy link
Member Author

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.

@jrobinAV jrobinAV removed the good first issue New-contributor friendly label Jan 25, 2024
@jrobinAV jrobinAV added the good first issue New-contributor friendly label Feb 9, 2024
@FlorianJacta
Copy link
Member Author

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

@FlorianJacta
Copy link
Member Author

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)

@FabienLelaquais FabienLelaquais transferred this issue from Avaiga/taipy Apr 22, 2024
@jrobinAV
Copy link
Member

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.

Copy link

github-actions bot commented Jun 4, 2024

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.

@github-actions github-actions bot added the 🥶Waiting for contributor Issues or PRs waiting for a long time label Jun 4, 2024
@jrobinAV jrobinAV removed the 🥶Waiting for contributor Issues or PRs waiting for a long time label Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📄 Documentation Internal or public documentation good first issue New-contributor friendly 🟩 Priority: Low Low priority and doesn't need to be rushed
Projects
None yet
Development

No branches or pull requests

3 participants