Plotly Treemap question for font alignment of parent container

Hi.
Need help to custom treemap.
How to align horizontal center for the parent container?

import plotly.express as px

_all_box_name : list = ['parent0', 'parent1<br>asdflkassadfsadfsadf', 'item0<br>100', 'item1<br>123']
_sector : list = ['', '', 'parent0', 'parent1<br>asdflkassadfsadfsadf']
_volume : list = [0, 0, 332, 532]
_labels : list = {'parent0' : 'parent0', 'parent1<br>asdflkassadfsadfsadf' : 'parent1', 'item0' : 'item0 111', 'item1' : 'item1222'}

fig = px.treemap(
	parents = _sector,
	names = _all_box_name,
	values = _volume,
	width = 1024,
	height = 768,
	labels = _labels
)

fig.update_traces(    

	textposition="middle center", 
	textfont_size=33
)
fig.update_layout(uniformtext_minsize=8, uniformtext_mode='hide')

fig.layout.hovermode = False
fig.data[0].texttemplate = "<b>%{label}</b>"
fig.show()

Does no one knows?

hi @powerdev
This is an interesting problem. I think the problem arises because of the line break: <br>.

If I put the text on one line, parent1asdflkassadfsad, then it is centered.
If I put the text on two lines but shorten the second line, parent1<br>new, the top text stays in the center.

But taking your example, parent1<br>asdflkassadfsadfsadf, the bottom text is centered while the top text (parent1) will align to the left starting point of the bottom text, as we can see from your image.

If I understand correctly, you would like the top line of text and the bottom line of text to both be centered?

Hi.

You are correct. Both need to be centered.
And if there is more than two lines(multiple lines by any newline method) also be centered is expectation.
Need to highlight to you is that the any β€˜newline’ method is okay(I’m not only prefering β€˜br’ β€˜br’ is the way what only I know) to make multiple lines.

Any workaround possible to align multiple lines?
if there is any workaround, I can change the coding style. no problem.

hi @powerdev
Unfortunately, this is a bug. I just created an issue, reporting it.

Reopen it the issue accidentally closed at Alignment problem Β· Issue #4537 Β· plotly/plotly.py Β· GitHub