Skip to content
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

Charts disappeared #28

Closed
bondjimbond opened this issue May 15, 2020 · 15 comments
Closed

Charts disappeared #28

bondjimbond opened this issue May 15, 2020 · 15 comments

Comments

@bondjimbond
Copy link

Not sure why, but charts are not showing, and there are no errors reported.

See https://dc.arcabc.ca/islandora/object/dc%3Aroot -- the "Usage Statistics" dropdown appears at the bottom of the page, and expands as well, but no actual content appears. Nothing is revealed in the console.

Tried changing the JQuery version, no effect.

Even weirder -- the dropdown appears when logged out, but disappears when logged in.

Any ideas what could be happening?

@mjordan
Copy link
Collaborator

mjordan commented May 15, 2020

This is ringing a bell... did you open another issue recently about a chart not showing up? My first guess is that it's a caching issue. Did you just dial up page caching?

@bondjimbond
Copy link
Author

I brought it up on Slack, but didn't make an issue. Caching is my thought too, but I don't know what to do about it... can't turn off the caching.

@mjordan
Copy link
Collaborator

mjordan commented May 18, 2020

@bondjimbond only thing I can think of, and it's just a guess, is that at the moment the cache was built, there was a glitch in downloading the Chart.js javascript file from cloudfare. If that is true (and I have absolutely no idea if it is), I wonder if using a local copy, as described in #6, would help reduce the risk of it happening again.

@bondjimbond
Copy link
Author

That could work!

@mjordan
Copy link
Collaborator

mjordan commented May 28, 2020

@bondjimbond do you want me to work on #7 to see if that helps?

@bondjimbond
Copy link
Author

Do you mean #6? (#7 is closed.) That would be great if you have the time, thanks!

@mjordan
Copy link
Collaborator

mjordan commented May 31, 2020

Yes, sorry #6

@mjordan
Copy link
Collaborator

mjordan commented Jun 6, 2020

@bondjimbond looks like to use a local copy of Chart.js, you need to build it with npm or Bower (https://www.chartjs.org/docs/latest/getting-started/installation.html). It's not a single file JavaScript library. Do you still want to try this option?

@bondjimbond
Copy link
Author

Sure... Is there a way maybe for the module to first check if a local copy is installed, and then if not try for the remotely hosted copy?

@mjordan
Copy link
Collaborator

mjordan commented Jun 30, 2020

@bondjimbond can you try this?

  1. In your drupal/sites/all/libraries directory, create a subdirectory chartjs
  2. In your new chartjs directory, run wget https://github.com/chartjs/Chart.js/releases/download/v2.9.3/Chart.bundle.js
  3. You should now have a file called Chart.bundle.js.
  4. At admin/islandora/tools/islandora_usage_stats_charts, enter the URL to the newly downloaded Chart.bundle.js file, e.g. https://arcabc.ca/sites/all/libraries/chartjs/Chart.bundle.js

I'm entirely sure this will work, since I can't get either npm or bower to install Chart.js (untrusted certificate error). But it should.

@bondjimbond
Copy link
Author

Error when loading:

Failed to load resource: the server responded with a status of 404 ()
js_UMFtXMK85ue7pvck9drFrxxl8t-gwzIY6GQWiWk59b4.js:55 Uncaught ReferenceError: Chart is not defined at js_UMFtXMK85ue7pvck9drFrxxl8t-gwzIY6GQWiWk59b4.js:55

@mjordan
Copy link
Collaborator

mjordan commented Jun 30, 2020

In the module code the URL to the Chart library is marked as 'external', which according to https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_add_js/7.x should not be aggregated. Yet the filename in the 404 error you are seeing suggests it is being aggregated.

Can you confirm that the URL to Chart.bundle.js as defined in step 4 above is correct? Test it by copying it and then visiting it in a private window.

@mjordan
Copy link
Collaborator

mjordan commented Jun 30, 2020

On my dev VM, using the URL http://localhost:8000/sites/all/libraries/chartjs/Chart.bundle.js and with Javascipt aggregation enabled, charts are working for me. I'm not getting the 404 error you are seeing. Let me know if your URL is correct and we'll take it from there.

@bondjimbond
Copy link
Author

Whoops, made a mistake in my wget apparently. Yep, it's working now!

@mjordan
Copy link
Collaborator

mjordan commented Jun 30, 2020

Very good. I've documented this over at #6 and will update the readme accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants