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

Issue fork charts-3403110

Command icon 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

jaymehls created an issue. See original summary.

andileco’s picture

Issue tags: -JavaScript +JavaScript

@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.

jaymehls’s picture

Issue tags: -JavaScript +JavaScript

@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

sarwan_verma made their first commit to this issue’s fork.

sarwan_verma’s picture

StatusFileSize
new476 bytes

Hi ,
I have fixed this issue "Highcharts - jQuery Once console errors" and also attached patch ,
please review and verify.

sarwan_verma’s picture

Status: Active » Needs review
andileco’s picture

Status: Needs review » Needs work

@sarwan_verma, your patch addresses part of the issue, but the JS file needs to be updated too. Currently, it looks like:

$('.charts-highchart').once().each(function () {

and it will need to look more like:

once('add_chart_attributes', '.charts-highchart', context).forEach(

See: https://www.drupal.org/docs/drupal-apis/javascript-api/javascript-api-ov...

NicholasS made their first commit to this issue’s fork.

nicholass’s picture

I 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).

andileco’s picture

StatusFileSize
new25.35 MB

Hey 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.

viren18febS made their first commit to this issue’s fork.

viren18febs’s picture

Status: Needs work » Needs review

I have updated the info file & commit the changes, please review.

ao5357 made their first commit to this issue’s fork.

netsliver’s picture

Title: Highcharts - jQuery Once console errors » jQuery Once console errors
StatusFileSize
new4.99 KB

Hello, new patch for all libraries

ignore, I hadn't seen the merge 70...

netsliver’s picture

emircanerkul’s picture

Attaching branch changes as a diff file.

bluegeek9 made their first commit to this issue’s fork.

bluegeek9 changed the visibility of the branch 5.0.x to hidden.

bluegeek9’s picture

Status: Needs review » Reviewed & tested by the community

I was able to use charts on Drupal 10 with this patch.

andileco’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.