def update_graph_3D(focus, sizeref, secteur_selected, chantier): if secteur_selected == {}: return empty_figure() else: try: df = format_df_vector( memoized_data(chantier, "actif", "topographie", "topo.csv") ) secteur = secteur_selected["secteur"] cibles = secteur_selected["cible"] with engine.connect() as con: query1 = f"SELECT * FROM cible_param where nom_chantier = '{chantier}' and masquer = 'x'" query3 = f"SELECT * FROM secteur where nom_chantier = '{chantier}' and nom_secteur='{secteur}'" secteur_params = pd.read_sql_query(query3, con=con) cibles_masque = pd.read_sql_query(query1, con=con).nom_capteur.tolist() liste_cibles = df.cible.tolist() for i in cibles_masque: try: liste_cibles.remove(i) except ValueError: pass df = df[df.cible.isin(liste_cibles)] lat1 = secteur_params.lat1[0] lat2 = secteur_params.lat2[0] lon1 = secteur_params.lon1[0] lon2 = secteur_params.lon2[0] return graph_vecteurs(df, lat1, lat2, lon1, lon2, secteur, cibles, sizeref, focus) except KeyError: return empty_figure()
def affichage_courbe_capteur(selectedData, chantier): try: ''' SelectedData : dictionnaire retourner par plotly lors d'une sélection sur la zone graphique''' '''En fonction du type de capteur sélectionné sur la carte la méthode appelle des focntions spécifiques pour récuper les données les mettre en forme et tracer les courbes''' customdata = selectedData["points"][0]["customdata"] text = selectedData["points"][0]["text"] if customdata == "cible": df = memoized_data(chantier, "actif", "topographie", "topo.csv") df = utils_topo.format_df(df, text, angle=0, repere="xyz") fig = utils_topo.graph_topo(df, height=550, spacing=0.06, showlegend=False) elif customdata == "inclino": fig = utils_inclino.graph_inclino(chantier, text, height=550) elif customdata == "tirant": fig = utils_tirant.graph_tirant(chantier, text, height=550, mode=2) elif customdata == "jauge": fig = utils_jauge.graph_jauge(chantier, text, height=550) elif customdata == "piezo": fig = utils_piezo.graph_piezo(chantier, text) else: fig = empty_figure() return (text, fig, sous_titre(customdata)) except: return "", empty_figure(), "Aucune donnée existante pour cet élément"
def update_graph_jauges(chantier, secteur_selected): ''' recupère la liste des jauges se trouvant dans le secteur selectioné''' try: liste_jauges = secteur_selected["jauge"] return graph_jauge(chantier, liste_jauges) except: return empty_figure()
def affichage_map(chantier, reload): ''' Voir utils_maps pour plus d'information sur la fonction update_map_chantier ''' try: return update_map_chantier(chantier), "" except: return empty_figure(), "Aucune donnée à afficher"
def update_time_serie(ref, secteur_selected, chantier): if secteur_selected == {}: return empty_figure(), "", "" else: secteur = secteur_selected["secteur"] if ref == "secteur": try: with engine.connect() as con: query = f"SELECT * FROM secteur_param WHERE nom_chantier='{chantier}' AND nom_secteur='{secteur}' " angle = pd.read_sql_query(query, con=con).angle[0] subtitle = "N, T, Z (mm)" repere = "ntz" except IndexError: angle = 0 subtitle = "X, Y, Z (mm)" repere = "xyz" else: angle = 0 subtitle = "X, Y, Z (mm)" repere = "xyz" df = memoized_data(chantier, "actif", "topographie", "topo.csv") list_capteur = secteur_selected["cible"] with engine.connect() as con: query1 = f"SELECT * FROM cible_param where nom_chantier = '{chantier}' and masquer = 'x'" cibles_masque = pd.read_sql_query(query1, con=con).nom_capteur.tolist() for i in cibles_masque: try: list_capteur.remove(i) except ValueError: pass if angle == None: df = format_df(df, list_capteur, 0) fig = graph_topo(df, height=700) return fig, "Aucun référentiel renseigné pour ce secteur" else: df = format_df(df, list_capteur, angle, repere=repere) fig = graph_topo(df, height=700) return fig, subtitle, ""
def display_right_content(options, clickData, chantier): ''' Option 1 : Manipulation -> Affiche la courbe CORRESPONDANT au capteur selectionné directement sur la carte Option 2 : Modification -> Affiche une fenètre de modification des paramètre avec zone de saisie et enregistrement des modifs Option 3: Selection -> Affiche un menu déroulant permettant de sélectionné un secteur pré-défini et un bouton renvoyant à la page de synthèse par secteur ''' if options == "control-map": if clickData: return [ dbc.Row(html.H3(id="titre_graph"), justify="center"), dbc.Row(dbc.Label(id="sous_titre_graph"), justify="center"), dcc.Loading( id="loading-graph", color="#FF8C00", type="graph", children=dcc.Graph(id="courbe_capteur", figure=empty_figure()), ), ] else: return [] elif options == "modify-map": return [ html.Br(), html.Br(), dbc.Card( [ dbc.CardHeader( dbc.Row(html.H4("Ajouter ou modifier"), justify="center")), collapse, dbc.CardBody([ dcc.Dropdown( id="type_option", style={"color": "black"}, options=[ { "label": "Ajouter", "value": 1 }, { "label": "Modifier", "value": 2 }, { "label": "Supprimer", "value": 3 }, ], placeholder="Options", clearable=False, ), html.Br(), dcc.Dropdown( id="type_param", style={"color": "black"}, options=[ { "label": "Secteur", "value": 1 }, { "label": "Inclinomètre", "value": 3 }, { "label": "Tirant", "value": 4 }, { "label": "Jauge", "value": 5 }, { "label": "Piezomètre", "value": 6 }, ], placeholder="Choix du paramètre", clearable=False, ), html.Br(), dbc.Input( placeholder="Nom du paramètre", id="nom_param_1", style={"display": "none"}, ), dcc.Dropdown( id="nom_param_2", style={"display": "none"}, ), html.Br(), html.Br(), dbc.Row( dbc.Button( id="save-update", href="/chantier", n_clicks=0, className="fas fa-save", size="lg", ), justify="center", ), html.Br(), dbc.Row( html.Div(id="update-success", className="text-success"), justify="center", ), ]), ], style={"width": "41rem"}, ), ] elif options == "select-map": with engine.connect() as con: query3 = f"SELECT * FROM secteur where nom_chantier = '{chantier}'" liste_secteurs = pd.read_sql_query(query3, con=con).nom_secteur.tolist() options_secteur = [{ "label": secteur, "value": secteur } for secteur in liste_secteurs] return [ html.Br(), html.Br(), dbc.Card( [ dbc.CardHeader( dbc.Row(html.H4("Sélectionner un secteur"), justify="center")), dbc.CardBody([ dbc.Row(dbc.Label("Choix du secteur"), justify="center"), dbc.Row( dcc.Dropdown( id="secteur-selection", style={ "color": "black", "width": "150px" }, options=options_secteur, ), justify="center", ), html.Br(), dbc.Row( dbc.Button( id="go-secteur", href="/secteur", n_clicks=0, className="fas fa-chart-line", size="lg", ), justify="center", ), ]), ], style={"width": "41rem"}, ), ]
id="map-container", children=[ dbc.Row( html.H4( id="no-chantier-selected", children="Chargement des données en cours ...", ), justify="center", ), dcc.Graph( id="map-chantier", config={ "scrollZoom": True, "modeBarButtonsToRemove": ["lasso2d"], }, figure=empty_figure(), ), html.Br(), dbc.Row( [ dbc.Tabs( [ dbc.Tab( labelClassName= "fas fa-hand-pointer", tab_id="control-map", ), dbc.Tab( labelClassName="fas fa-sliders-h", tab_id="modify-map", ),
def update_graphs(secteur_selected, nb_courbes, nb_courbes2, nb_courbes3, profondeur, chantier): try: ''' Extraction du nom de l'inclino se trouvant dans le secteur sélectionné''' inclino = secteur_selected["inclino"] ''' Telechargement des données normales et tangentielles associées à l'inclino''' dfnorm = get_data(chantier, "actif", "inclinometrie", f"{inclino}_norm.csv", sep=False) dftan = get_data(chantier, "actif", "inclinometrie", f"{inclino}_tan.csv", sep=False) ''' Creation de l'ensemble des figure et tables (voir méthodes ci-dessous''' fig1 = create_graph_1(dfnorm, chantier, inclino, nb_courbes3, "normal") fig2 = create_graph_1(dftan, chantier, inclino, nb_courbes3, "tangentiel") fig3 = create_graph_2(dfnorm, chantier, inclino, nb_courbes, "normal") fig4 = create_graph_2(dftan, chantier, inclino, nb_courbes, "tangentiel") fig5 = create_3d_graph(dfnorm, dftan, chantier, inclino, nb_courbes) fig6 = create_graph_3(dfnorm, chantier, inclino, nb_courbes2, "normal") fig7 = create_graph_3(dftan, chantier, inclino, nb_courbes2, "tangentiel") fig8 = create_graph_4(dfnorm, chantier, inclino, profondeur, "normal") fig9 = create_graph_4(dftan, chantier, inclino, profondeur, "tangentiel") tablenorm = (dfnorm.set_index("profondeur").T[[ 2, 5, 10, 20, 30, 40, 50, 60 ]].iloc[-15:, :]) tablenorm = tablenorm.reset_index().rename(columns={"index": "date"}) tabletan = (dftan.set_index("profondeur").T[[ 2, 5, 10, 20, 30, 40, 50, 60 ]].iloc[-15:, :]) tabletan = tabletan.reset_index().rename(columns={"index": "date"}) return ( fig1, fig2, fig3, fig4, fig5, fig6, fig7, fig8, fig9, tablenorm.to_dict("rows"), tabletan.to_dict("rows"), ) except: return ( empty_figure(), empty_figure(), empty_figure(), empty_figure(), empty_figure(), empty_figure(), empty_figure(), empty_figure(), empty_figure(), [], [], )
def update_graph_tirants(secteur_selected, chantier): try: liste_tirants = secteur_selected["tirant"] return graph_tirant(chantier, liste_tirants) except: return empty_figure(), empty_figure()
dbc.Container( dcc.Slider( id="size_ref", min=0, max=1000, step=10, value=500, marks={ 0: "Zoom Min.", 500: "50%", 1000: "Zoom Max.", }, ) ), html.Br(), dcc.Graph(id="graph-3D", figure=empty_figure()), html.Hr(), html.Br(), dbc.Row(html.H4("Dépalcement des cibles"), justify="center"), dbc.Row(html.H5(id="subtitle_topo"), justify="center"), html.Br(), dbc.Row(dbc.Label("Référentiel de mesure"), justify="center"), dbc.Row( dcc.Dropdown( id="absolu_NTZ", style={"color": "black", "width": "150px"}, options=[ {"label": "Absolu", "value": "absolu"}, {"label": "Secteur", "value": "secteur"}, ], value="absolu",