-
Notifications
You must be signed in to change notification settings - Fork 69
[FIX] Charts: Ensure Chart js extension are loaded on chart creation #7563
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
base: master
Are you sure you want to change the base?
[FIX] Charts: Ensure Chart js extension are loaded on chart creation #7563
Conversation
|
@rrahir @LucasLefevre cherrypicking of pull request #7379 failed. stdout: Either perform the forward-port manually (and push to this branch, proceeding as usual) or close this PR (maybe?). In the former case, you may want to edit this PR message as well. More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port |
74b36d1 to
e8f82b7
Compare
|
this one is troublesome, the code to convert to images clearly depends on chart js and therefore browser behaviour. |
this tries to reflect the reality regarding the possible absence of chartJs when running the library. The typing assumes that the library is always loaded but when it's not, a random line of code will crash while trying to access window.Chart. Through this revision, we explicitely handle the absence of chart js and throw an explicit error.
At the moment, when the chart js library is not loaded or if it is missing some plugins (like geo chart or funnel), trying to convert a chart to an image file or and image url will crash. This revision adds some checks to let the conversion fail silently without breaking the whole conversion flow. This will prove useful when trying to convert charts during an xlsx export if the code is running server side and without a proper access to chart.js. Task: 0
When calling the method chartToImage, the chartJs extensions might not be loaded as we load them conditionally when mounting a chart. Hence, calling `ChartToImage` when there are no visible charts in the viewport or if we just instantiate a model without loading a component `Spreadsheet`, the extensions will be missing. Right now, the plugins/extensions are not fundamental to convert a chart to an image but this becomes problematic with the arrival of future charts (for instance Funnel). This commit adds a check to ensure that the extensisons are loaded and unloads them after use as they can cause crashes when using the global `ChartJs` variable elsewhere (see #6076). Task: 5214007 X-original-commit: d146422
e8f82b7 to
b5bbf00
Compare
|
@VincentSchippefilt could you have a look ? since it is a forwardport at firt but I added the suggestion we talked about :) |

When calling the method chartToImage, the chartJs extensions might not be loaded as we load them conditionally when mounting a chart. Hence, calling
ChartToImagewhen there are no visible charts in the viewport or if we just instantiate a model without loading a componentSpreadsheet, the extensions will be missing.Right now, the plugins/extensions are not fundamental to convert a chart to an image but this becomes problematic with the arrival of future charts (for instance Funnel).
This commit adds a check to ensure that the extensisons are loaded and unloads them after use as they can cause crashes when using the global
ChartJsvariable elsewhere (see #6076).Task: 5214007
Description:
description of this task, what is implemented and why it is implemented that way.
Task: TASK_ID
review checklist
Forward-Port-Of: #7379