Created
January 11, 2022 11:03
-
-
Save cirops/015ebfd89ebbcdc5e300414bc34d7b2c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dash | |
from dash import dcc | |
from dash import html | |
from dash.dependencies import Input, Output | |
import dash_bootstrap_components as dbc | |
import plotly_express as px | |
import plotly.graph_objects as go | |
import numpy as np | |
import pandas as pd | |
import json | |
# li = [] | |
# df = pd.read_csv("HIST_PAINEL_COVIDBR_2020_Parte1_21dez2021.csv", sep=";") | |
# li.append(df) | |
# df = pd.read_csv("HIST_PAINEL_COVIDBR_2020_Parte2_21dez2021.csv", sep=";") | |
# li.append(df) | |
# df = pd.read_csv("HIST_PAINEL_COVIDBR_2021_Parte1_21dez2021.csv", sep=";") | |
# li.append(df) | |
# df = pd.read_csv("HIST_PAINEL_COVIDBR_2021_Parte2_21dez2021.csv", sep=";") | |
# li.append(df) | |
# df = pd.concat(li, axis=0, ignore_index=True) | |
# df_states = df[(~df["estado"].isna())& (df["codmun"].isna())] | |
# df_brasil = df[df["regiao"]=="Brasil"] | |
# df_states.to_csv("df_states.csv") | |
# df_brasil.to_csv("df_brasil.csv") | |
df_states = pd.read_csv("df_states.csv", sep=",") | |
brazil_states = json.load(open("geojson/brazil_geo.json", "r")) | |
df_data = df_states[df_states["estado"]== "RJ"] | |
# CRIAÇÃO DO MAPA | |
# Instaciação do Dash | |
app = dash.Dash(__name__, external_stylesheets=[dbc.themes.CYBORG]) | |
fig = px.choropleth_mapbox(df_states, locations="estado", color="casosNovos", center={"lat":-16.95, "lon": -47.78}, zoom=4, geojson=brazil_states, color_continuous_scale="Redor", opacity=0.4, hover_data={"casosAcumulado": True, "casosNovos": True, "obitosNovos": True, "estado": True}) | |
fig.update_layout(paper_bgcolor="#242424", mapbox_style="carto-darkmatter") | |
fig2 = go.Figure(layout={"template": "plotly_dark"}) | |
fig2.add_trace(go.Scatter(x=df_data["data"], y=df_data["casosAcumulado"])) | |
fig2.update_layout(paper_bgcolor="#242424", plot_bgcolor="#242424", autosize=True, margin=dict(l=10, r=10, t=10, b=10)) | |
#Layout | |
# app.layout = dbc.Container( | |
# dbc.Row( | |
# [dbc.Col( | |
# [html.Div( | |
# [html.Img( | |
# id="logo", | |
# src=app.get_asset_url("logo_dark.png"), | |
# height=50,html.H5("Evolução COVID-19"), | |
# dbc.Button("BRASIL", color="primary", id="location_button", | |
# size="lg") | |
# ], | |
# style={}), | |
# html.P("Informe a data na qual deseja obter informações:", style={"margin-top": "40px"}), html.Div(id="div-test", children=[dcc.DatePickerSingle( | |
# id="date-picker",min_date_allowed=df_brasil["data"].min(),max_date_allowed=df_brasil["data"].max(),initial_visible_month=df_brasil["data"].min(),date=df_brasil["data"].max(),display_format="MMMM D, YYYY",style={"border": "0px solid black"}]) | |
# dcc.Graph(id="line-graph", figure=fig2)]),dbc.Col([dcc.Graph(id="choropleth-map",figure=fig)) | |
if __name__ == "__main__": | |
app.run_server(debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment