Problem/Motivation
When using the Highcharts module and rendering the charts on my page, I see the attached errors in the console. This appears to be due to the deprecation of the `jquery.once` library and requires a replacement to `once`.
Steps to reproduce
1. Render a graph on a Drupal 10 site using Highcharts
2. Check the console for any JS errors
I am currently only using the highcharts submodule for this but there may be other integrations which require this update.
Proposed resolution
Update the existing libraries and Javascript to switch the dependencies from jquery.once to just once and swap the implementation in the JavaScript to use the once() function as per this documentation: https://www.drupal.org/node/3158256
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | 3403110-highcharts---jquery--28c75207dbcbebb90152d865261dd1d8e0375e85.diff | 12.44 KB | emircanerkul |
| #11 | Screenshare - 2023-12-06 11_34_26 AM.mp4 | 25.35 MB | andileco |
| #5 | Highcharts_jQuery_Once_errors-3403110.patch | 476 bytes | sarwan_verma |
| CleanShot 2023-11-21 at 11.43.03.png | 103.61 KB | jaymehls |
Issue fork charts-3403110
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
andileco commented@jaymehls, I have been trying to depreciate the 8.x-3.x version of Charts in favor of 5.0.x for years. Is there any reason (like a custom module) that you have not upgraded to the 5.0.x version? If not, that's definitely the next step to take, and you'll inherit lots of other improvements too.
Comment #3
jaymehls commented@andileco it makes sense regarding the deprecation. We are currently halfway through a Drupal 10 upgrade and we have a large amount of custom legacy code from about 5 years ago that is driving the creation of charts from a Webform (a class with over 1000 lines). As you can imagine the upgrade process for this is rather tough and will require some input to move to the new version, though if the recommended approach here is to upgrade, it might be the time to go ahead and do it.
If there are plans to pull support on the 3.x version at some point, we should probably do the upgrade as soon as we can.
Thanks
Comment #5
sarwan_verma commentedHi ,
I have fixed this issue "Highcharts - jQuery Once console errors" and also attached patch ,
please review and verify.
Comment #7
sarwan_verma commentedComment #8
andileco commented@sarwan_verma, your patch addresses part of the issue, but the JS file needs to be updated too. Currently, it looks like:
and it will need to look more like:
See: https://www.drupal.org/docs/drupal-apis/javascript-api/javascript-api-ov...
Comment #10
nicholassI am blocked from 5.x due to another module
Problem 1
- Root composer.json requires drupal/charts ^5.0, found drupal/charts[dev-5.0.x, 5.0.0-alpha1, ..., 5.0.x-dev] but these were not loaded, likely because it conflicts with another require.
Problem 2
- drupal/charts_field_formatter is locked to version dev-3369229-automated-drupal-10-charts-3.3 and an update of this package was not requested.
- drupal/charts_field_formatter dev-3369229-automated-drupal-10-charts-3.3 requires drupal/charts ^3.3 -> found drupal/charts[dev-3.x, 3.3.0, 3.4.0, 3.5.0, 3.x-dev (alias of dev-3.x)] but it conflicts with your root composer.json require (^5.0).
Comment #11
andileco commentedHey NicholasS, a plug for migrating to 5.x, as that capability is in-built in Charts 5.x (see the attached video). Obviously, it can be complicated to do, especially when that module blocks upgrading, but I think it will be very well-worth it if you can finagle it.
Comment #13
viren18febs commentedI have updated the info file & commit the changes, please review.
Comment #15
netsliverHello, new patch for all libraries
ignore, I hadn't seen the merge 70...
Comment #16
netsliverComment #17
emircanerkul commentedAttaching branch changes as a diff file.
Comment #20
bluegeek9 commentedI was able to use charts on Drupal 10 with this patch.
Comment #22
andileco commented