créé moi une app ou je peux avoir un graphe qui fait le suivi du coût en $ par point d'injection pour trois produits chimiques différents (PERBREAK, PERCOR INHIB, PERDEFLOC K01) et les points d'injection sont au nombre de 10 (SPT_T500_IN, SPT_MANGARA_ARRIVAL, CPF_V100_IN, PAD_Z_MANIFOLD_PROD, PAD_Y_MANIFOLD_PROD, PAD_Y03_CONTROL_LINE, PAD_Y04_CONTROL_LINE, PAD_Y05_CONTROL_LINE, PAD_T_MANIFOLD_PROD_PAD_K_MANIFOLD_PROD). Il faut également un total par produit chimique
To upload files, please first save the app
import streamlit as st
import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
# Configuration de la page
st.set_page_config(layout="wide", page_title="Chemical Cost Tracker")
# Titre
st.title("Chemical Cost Tracking Dashboard")
# Création des données exemple
injection_points = [
'SPT_T500_IN', 'SPT_MANGARA_ARRIVAL', 'CPF_V100_IN',
'PAD_Z_MANIFOLD_PROD', 'PAD_Y_MANIFOLD_PROD', 'PAD_Y03_CONTROL_LINE',
'PAD_Y04_CONTROL_LINE', 'PAD_Y05_CONTROL_LINE', 'PAD_T_MANIFOLD_PROD',
'PAD_K_MANIFOLD_PROD'
]
chemicals = ['PERBREAK', 'PERCOR INHIB', 'PERDEFLOC K01']
# Création d'un DataFrame avec des coûts exemple
data = {
'Injection_Point': [],
'Chemical': [],
'Cost_USD': []
}
# Génération de données exemple
import random
for point in injection_points:
for chemical in chemicals:
data['Injection_Point'].append(point)
data['Chemical'].append(chemical)
data['Cost_USD'].append(round(random.uniform(100, 1000), 2))
df = pd.DataFrame(data)
# Création des visualisations
st.header("Cost per Injection Point")
# Graphique principal
fig = px.bar(df,
x='Injection_Point',
y='Cost_USD',
color='Chemical',
barmode='group',
title='Cost Distribution by Injection Point and Chemical')
fig.update_layout(
xaxis_title="Injection Point",
yaxis_title="Cost (USD)",
legend_title="Chemical Product",
xaxis_tickangle=-45
)
st.plotly_chart(fig, use_container_width=True)
# Calcul et affichage des totaux
st.header("Total Cost by Chemical")
total_by_chemical = df.groupby('Chemical')['Cost_USD'].sum().reset_index()
fig_total = go.Figure(data=[
go.Bar(
x=total_by_chemical['Chemical'],
y=total_by_chemical['Cost_USD'],
text=total_by_chemical['Cost_USD'].round(2),
textposition='auto',
)
])
fig_total.update_layout(
title='Total Cost per Chemical',
xaxis_title="Chemical",
yaxis_title="Total Cost (USD)",
)
st.plotly_chart(fig_total, use_container_width=True)
# Affichage des données détaillées
st.header("Detailed Data")
st.dataframe(df)
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?