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

[v1.5.4] [Moodle 4.1.13] JS console error: "chartjs-lazy.js:1 Invalid scale configuration for scale" (xAxes + yAxes) #127

Open
danowar2k opened this issue Jan 3, 2025 · 0 comments

Comments

@danowar2k
Copy link

Moodle Version in use
Moodle 4.1.13

** Plugin Version **
v1.5.4

Describe the bug
On the page mod/pdfannotator/view.php?id=31156&action=statistic (as an example), the graph statistic throws console errors (unknown yet if that affects anything). See the screenshot.

Going into the code, it originates in shared/statistics.js. See

scales: {
xAxes: [{
stacked: true,
ticks: {
autoSkip: false
}
}],
yAxes: [{
ticks: {
beginAtZero: true,
precision: 0,
max: maxValue + 2
}
}]
},
.
The xAxes/yAxes scales configuration used to call Moodle's chartjs library is an array of a single object. Moodle's chartjs library validates the scales config to ensure it's an object, see https://github.com/moodle/moodle/blob/ab5692acdf1f9a2b3cf06986f49b951558793f38/lib/amd/src/chartjs-lazy.js#L7282-L7289. (master, Moodle 4.1.13 is the same).

The simple solution seems to be to change the scales config from an array of a single object to just a single object. At least this way the error vanishes from the console log.

To Reproduce
Steps to reproduce the behavior:

  1. View mod/pdfannotator/view.php?id=REPLACE_WITH_ID&action=statistic
  2. Open the console log, there is the error

Expected behavior
No console error. As the scale config is ignored, there should probably be differences in the scales.

Screenshots
image

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser Chrome
  • Version 131.0.6778.205
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

1 participant