Spaces:
Sleeping
Sleeping
File size: 1,398 Bytes
d90a900 b4ad7d9 a6fbff6 d90a900 b4ad7d9 d90a900 b4ad7d9 d90a900 b4ad7d9 d90a900 b4ad7d9 d90a900 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
from bokeh.plotting import figure
from bokeh.layouts import row
from bokeh.models import ColumnDataSource
import pandas as pd
import panel as pn
from bokeh.models import NumeralTickFormatter
from bokeh.models.widgets import Select
from bokeh.models import FactorRange
import panel as pn
taller = pd.read_excel("./taller.xlsx")
taller
taller["x"]= taller.apply(lambda row: (row["Cliente"], row["Tipo"]), axis=1 )
x_range= FactorRange(*taller["x"])
source = ColumnDataSource(taller)
options = [("total","Total") , ("porcentaje", "Porcentaje")]
select= Select(options=options, title="Seleccione una opcion")
p = figure(x_range= x_range, sizing_mode="scale_width")
bars= p.vbar(source=source, x="x", bottom=0, top="Reparaciones", width=0.8)
layout= row([select, p], sizing_mode="stretch_both")
def update_graph(attr, old, new):
global bars
p.renderers.remove(bars)
if new == "total":
bars= p.vbar(source=source, x="x", bottom=0, top="Reparaciones", width=0.8)
y_formatter= NumeralTickFormatter(format="0,0")
p.yaxis.formatter= y_formatter
elif new =="porcentaje":
bars= p.vbar(source=source, x="x", bottom=0, top="Porcentaje", width=0.8)
y_formatter= NumeralTickFormatter(format="0%")
p.yaxis.formatter= y_formatter
select.on_change("value",update_graph)
bokeh_panel = pn.pane.Bokeh(layout)
bokeh_panel.servable() |