-
Notifications
You must be signed in to change notification settings - Fork 718
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
100's of js errors - Error: <rect> attribute width: A negative value is not valid #295
Comments
From this code ( minified ) code ie n.setAttribute(i, a)
|
Can you share a code-pen or codesandbox ? |
the code is exact copy of the sample given as you can see by the chart rendered on the right side of chrome in Dev mode. The issue I think only occurs when the browser window is reduced in size. The JavaScript needs to not call setattribute for width of object with negative number. Assume something odd in the scaling logic gives a negative width |
Yes, you are right. I finally managed to replicate this. The following code in charts/src/js/charts/BaseChart.js Lines 85 to 99 in 136b914
The draw function recalculates the width of the chart here charts/src/js/charts/BaseChart.js Lines 136 to 138 in 136b914
As it turns out the width that's being returned is negative. Which cascades down to I replicated this is while working on Frappe Framework desk, there are pages and a sidebar to toggle them. When a page with a sidebar is hidden and the window is resized, this error occurs. Probably because it's not visible. I'll have to investigate this further. The most straightforward way it to destroy the event listener when the chart is not required, but in most cases this is not practical. If we look at the code in Lines 69 to 75 in 136b914
The right and left padding is added to the overall width. Having a negative padding can be a cause of the problem too. Does your element have any negative padding? UPDATETurns out the charts/src/js/charts/BaseChart.js Line 161 in 136b914
Need to figure out why the width is zero in your case. Are you sure that's the only chart your have created on that page? Also can try running the |
ok will review this fix via npm |
did npm and bench update, can see new version on charts loaded. Still getting same errors, assume npm install is not conflicting with some basic fappe/erpnext chart package. Maybe way to go is to protect the calls from negative values and console log a helpful error message |
Yeah, perhaps we have to do this. I was avoiding this, trying to solve the problem at the root. But then, it makes sense to have the safety there since the On another note, the screenshot on your issue description is a frappe page, is it possible for you to send me the JS code for that page? Including the page controllers? |
@ollyboy I managed to replicate a lot of these issues and have fixed them in a recent release. Can you please verify the fix |
Code I am using. Reads a doc and displays a chart on a frappe built page. code is pasted into the .js that frappe generates for each new page.
|
Results from this code. Note I have taken all hooks.py references to the chart library out. Frappe seems to find the npm module. Checked and the version is 1.5.2. Stiil getting errors from:
How do I get frappe to use the non minified charts js for testing debug ?? I dont know how frappe is finding and including the npm installed js and css?? |
A lot of these errors are fixed in recent commits 222cbb6, 773f93c and 9d03d50 It's released you can check it out.
Here are the steps
This will link frappe charts to the local version To activate live reloading, you need to do that following
With this, bench will rebuild the library with every change in frappe charts. You'll get live reloading. |
Did this: yarn add frappe-charts Did a yarn list in the frappe folder and it still says version 1.3.0 Still getting heaps of errors, don't think it's using the local package BTW: I am running frappe in nginx production mode on a google compute ubuntu server |
Can we clarify how to use local version 1.5.2, followed instructions but frappe still used the charts 1.3 native to frappe. |
In this case I'd recommend not run the local development version. You can unlink using In production mode, live reloading of packages is not available. You should upgrade the package using npm normally |
The fix made previously would just work on bar graphs and not path and circle. I just have to add the validation on these components and it'll start working. Anyway this means that the fix is working without disruption of any functionality For now, you can continue working with charts as is. In later releases I shall fix it for other SVG components as well. |
OK, the yarn environment looks a bit messy. is that an issue? Should this be a new frappe issue... mcd_steven@erp-next:~/frappe-bench/apps/frappe$ yarn upgrade mcd_steven@erp-next:~/frappe-bench/apps/frappe$ yarn install mcd_steven@erp-next:~/frappe-bench/apps/frappe$ yarn check mcd_steven@erp-next:~/frappe-bench/apps/frappe$ npm list | grep ERR |
Any updates? |
I don't think this works anymore with the new frappe v14 build system. Are there any new instructions? |
When resizing windows using chrome developer tools we get lots of javascript errors. To me this is a show stopper for production use of charts
The text was updated successfully, but these errors were encountered: