I have two problems I’m unable to solve and I hope somebody has a hint.
The layout now looks like this:
Problem 1: is it possible to make only the word Total in the lower left bold, like the values in that row? The app consists of two barcharts and a listgroup. I tried the same lambda function on the word “Total” as I used for the rest, adjusting pre and suffix, it did not work and I don’t see a font-weight property.
Problem 2: the gridlines in the black chart. When I give a range for the gridlines y=1.5, y=2.5 etc, Total is not displayed in the chart. What I actually want is those lines between the bars (y=1.5 to y=7.5 step 1) and keep Total and the bar above Total. I tried horizontal lines but a white horizontal line of 1px is still darker than a lightgrey gridline.
I hope somebody has a hint, besides that maybe this is not a good idea The code of the first barchart (black one):
Code
def create_fig_money(data):
#VISUAL PRINTS REVENUE PER CATEGORY THIS MONTH
#INPUT IS DATA = SUMMARIZED CATEGORY, REVENUE, DELTA PM AND DELTA PM%
fig = go.Figure()
fig.add_trace(go.Bar(
y=data['categoryName'],
x=data['barLength'],
text=data['nettoPrice'],
orientation='h',
#the bars
marker=dict(
color='rgba(0, 0, 0, .9)',
cornerradius=15,
line=dict(color='rgba(0, 0, 0, 1.0)',
width=1)
)
))
#labels at the end of bar, lambda function to create a bold for the total value
fig.update_traces(texttemplate=data['categoryName'].apply(lambda x: '<b>%{text:.2s}</b>' if x == 'Total' else '%{text:.2s}'), textposition='outside')
fig.update_xaxes(showticklabels=False)
fig.update_yaxes( dict(ticksuffix=" " ),showgrid=True, gridwidth=1, gridcolor='LightGrey')
fig.update_layout(
margin=dict(l=5, r=5, t=25, b=5),
plot_bgcolor='white',
title = {
'text': 'AC',
'y':1, # new
'x':0.5,
'xanchor': 'center',
'yanchor': 'top' # new
},
)
fig.add_vline(x=0, line_dash="solid", line_width=1)
fig.add_hline(y=0.5, line_dash="solid", line_width=2)
return dcc.Graph(figure = fig)