Have a nice day, everyone.
So I have a factory that has a few machines and a few people who make things.
I have put the data into a dataframe that I need to display.
I did it, but I need to add buttons and Iβm asking for help with this.
- How can I add another list just below the machines, but with last names?
- How to make it so that there is only one column per day, with the sum of volumes, but at the same time, both filters work?
from dash import Dash, html, dcc
import plotly.express as px
import pandas as pd
app = Dash(__name__)
df = pd.DataFrame({
"date": [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7],
"volume": [0.805, 5.806, 4.520, 4.977, 4.134, 2.483, 5.388, 4.806, 1.906, 3.738, 4.406, 1.951, 5.852, 3.431, 5.881, 3.521, 0.165, 4.908, 4.872, 4.361, 3.643, 1.449, 0.124, 0.393, 2.081, 1.140, 5.690, 2.498, 2.515],
"surname":["Ivanov", "Petrov", "Ivanov", "Sidorov", "Ivanov", "Petrov", "Sidorov", "Ivanov", "Ivanov", "Petrov", "Sidorov", "Ivanov", "Ivanov", "Petrov", "Sidorov", "Sidorov", "Sidorov", "Sidorov", "Ivanov", "Petrov", "Petrov", "Petrov", "Ivanov", "Petrov", "Sidorov", "Sidorov", "Sidorov", "Sidorov", "Sidorov"],
"machine":["4", "3", "2", "1", "1", "3", "2", "2", "3", "3", "4", "3", "4", "3", "3", "1", "3", "1", "1", "1", "1", "1", "2", "3", "2", "2", "2", "2", "3"]
})
fig = px.bar(df, x="date", y="volume", color="machine", text='volume')
fig.update_traces(textposition='inside')
fig.update_layout(uniformtext_minsize=8, uniformtext_mode='hide')
fig.update_layout(
xaxis = dict(
tickmode = 'linear'
)
)
app.layout = html.Div(children=[
html.H1(children='Some chart title'),
dcc.Graph(
id='example-graph',
figure=fig
)
])
if __name__ == '__main__':
app.run_server(debug=True, port="8080",host="0.0.0.0", use_reloader=True)