-
-
Notifications
You must be signed in to change notification settings - Fork 493
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 enhancements - onclick and dynamic options #1579
Echart enhancements - onclick and dynamic options #1579
Conversation
@natankeddem, regarding your comments here: #1562 (comment) it seems you already have a good start on understanding how these tests should proceed - perhaps if you continue in this space while I look at developing demos? |
Yes, I can continue coming up with a test plan. Although, as described before we probably need to talk about how we want to go about it due to to way this library renders its contents. @rodja @falkoschindler any input on how you would like to process purely graphical tests would be helpful. Perhaps I can capture golden images of the chart rendering to compare against or something similar? Before I get there I just wanted to take tonight to review what you have already implemented. |
That's really tricky. We have tried to avoid these kind of tests until know. For example the |
Okay, I will try to limit testing to checking the superficial element div/canvas rather than trying to interact directly with the internal rendering for now and see what we can get done. |
I added a few tests to start things off. The expansion test will fail until #1570 hopefully fixes that issue. I still haven't gotten time to play around with the events. Do you have any test charts you have been playing around with this event that you could share? |
@thetableman the mime-type issue looks familiar. Maybe it's #1510? |
Yes, it's probably related. I didn't have an issue at work yesterday where I run 1.3.13 on Win 10 in Firefox but this was at home on Win 11 (but still 1.3.13 and Firefox). Not sure if the os is relevant though as the error suggests it's to do with the js loading in a browser. I'm not experienced with JavaScript so this one is definitely beyond my understanding. |
If you point your browser toward |
Can you try adding the following at the top of your python script you are running before any other code: import mimetypes
mimetypes.add_type('application/javascript', '.js')
mimetypes.add_type('text/css', '.css') |
Yes, the javascript is accessible in the browser. The error isn't related to be able to find the resource but to do with importing it. |
Adding to the top of the running script had no effect but after adding to the top of the |
I am not sure I understand; can you be more specific on where you added that code to make things work? If that did in fact fix things; there might need to be a seperate PR to fix the issue. It shouldn't be specific to echarts and should affect any imports it appears. The way I understand it is there is some sort of Windows registry mime type usage information and somehow that makes things not work on random Windows computers. I didn't read into the nitty gritty to be honest. Here is something Django specific with some informative links. It appeared to be a widespread problem that causes issues in quite a few utilities/libraries in several different languages. https://www.django-unicorn.com/docs/troubleshooting/ |
You suggested I add the I've just done another commit with the change. |
Alright, I didn't realize what you were working on. Can you try removing it from echart.py and add it to the top of main.py(are you running this for docs demo or something else?). Make sure all the code I posted is above any other imports, hopefully autopep8 allows this. Make sure it isn't split as in the current echarts.py. This should give more data to whomever fixes this in the future. Hopefully this code can be added somewhere just once not in every element that needs to use imports. |
I came across the error whilst testing some demo scenarios so it seemed logical to just continue testing this change with them. I'll try placing the code in a |
I'm thinking it will eventually probably need to go on the top of |
Agree, my gut feeling is the Also agree it may be best to find somewhere more global for the |
Thanks for digging into this @thetableman and @natankeddem. This kind of errors are hard to track down. It would be really great to have the fix in a separate PR. Maybe |
PR #1594 has been submitted. |
# Conflicts: # nicegui/elements/echart.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR, @thetableman!
I looked it through and updated the code here and there:
- I removed the
pack()
function, since NiceGUI automatically transmits the selected event arguments to the server. There's no need to rename them here. - Fixing the mimetypes is already on main. No need to do it here.
ui.chart
andui.echart
are separate UI elements. I don't think there event classes should derive from another.- And I cleanup tests and documentation. Especially the demos could be shortened a bit to really focus on a single feature each.
I guess it's ready to merge on main. 😀
This PR replaces #1562 and proposes dynamic option parsing in addition to onclick callback.