-
-
Notifications
You must be signed in to change notification settings - Fork 605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EChart width on initial load #1563
Comments
Yes, there is something wrong with echart initial loading. I could further boil down the code to reproduce it: from nicegui import ui, Client
import random
@ui.page('/')
async def index(client: Client):
await client.connected()
with ui.card().classes('w-full bg-primary text-white'):
series = [random.random(), random.random()]
ui.echart({
'xAxis': {'type': 'value'},
'yAxis': {'type': 'category', 'data': ['A', 'B'], 'inverse': True},
'legend': {'textStyle': {'color': 'gray'}},
'series': [{'type': 'bar', 'name': 'Data', 'data': series}, ],
}).classes('w-full bg-white')
ui.run() Without the |
Maybe @natankeddem or someone else can have a look into this? |
I should have time to look into this tomorrow. |
So from some searching it appears like echarts doesn't like the fact that when closed; the expansion has the Issuing a |
So a few initial ideas:
echart = ui.echart({
'xAxis': {'type': 'value'},
'yAxis': {'type': 'category', 'data': ['A', 'B'], 'inverse': True},
'legend': {'textStyle': {'color': 'gray'}},
'series': [
{'type': 'bar', 'name': 'Alpha', 'data': series_1},
{'type': 'bar', 'name': 'Beta', 'data': series_2},
],
}).style('height: 600px').style('width: 600px')
ui.expansion('Expansion').classes('w-full bg-primary text-white').on('show', lambda: chart.refresh()) @rodja Do you think either of these are acceptable? I could also put in a PR for a utility method |
Thanks for looking into this @natankeddem! I saw there was a resize PR from a user called 'dabenny' - is that also you? I think these are both perfectly reasonable work-arounds for specific cases like the examples discussed (I'm leaning towards option 2) but there is a risk that this issue will continue to be raised by other users as the behavior is not in-keeping with other elements. |
That is not me. Do people typically have multiple Github accounts? |
@natankeddem Thanks for analyzing the issue and proposing the two solutions. Option 1 is suboptimal in my view because it does not allow simple dynamic sizing. But I like Option 2 and wonder if we could simply add |
@rodja in that case the init would either need
The |
The other idea which I am not sure how to implement yet is that we could have an event that fires in the javascript that would resize the chart on visibility change. I would need to research how this could be accomplished and if it is possible at all. |
I also think that an automatic resizing is the way to go. I'll look into #1570 shortly. |
Description
Consider the below minimal example of an EChart nested within a
ui.expansion
:The element doesn't show full width as expected but instead takes on a compact arbitrary width, after clicking the
Update
button the chart refreshes and shows at the expected width. The cause seems to be theui.expansion
element as when this is removed the issue doesn't occur.On initial load:
After clicking
Update
:The text was updated successfully, but these errors were encountered: