DEV: updates chart.js to 3.5.1 (#14107)

DEV: updates chart.js to 3.5.1 (#14107)

diff --git a/app/assets/javascripts/admin/addon/components/admin-graph.js b/app/assets/javascripts/admin/addon/components/admin-graph.js
index b6bf870..8df160a 100644
--- a/app/assets/javascripts/admin/addon/components/admin-graph.js
+++ b/app/assets/javascripts/admin/addon/components/admin-graph.js
@@ -27,14 +27,16 @@ export default Component.extend({
       data: data,
       options: {
         responsive: true,
-        tooltips: {
-          callbacks: {
-            title: (context) =>
-              moment(context[0].xLabel, "YYYY-MM-DD").format("LL"),
+        plugins: {
+          tooltip: {
+            callbacks: {
+              title: (context) =>
+                moment(context[0].label, "YYYY-MM-DD").format("LL"),
+            },
           },
         },
         scales: {
-          yAxes: [
+          y: [
             {
               display: true,
               ticks: {
diff --git a/app/assets/javascripts/admin/addon/components/admin-report-chart.js b/app/assets/javascripts/admin/addon/components/admin-report-chart.js
index 9e2d382..7711ca8 100644
--- a/app/assets/javascripts/admin/addon/components/admin-report-chart.js
+++ b/app/assets/javascripts/admin/addon/components/admin-report-chart.js
@@ -112,14 +112,16 @@ export default Component.extend({
       type: "line",
       data,
       options: {
-        tooltips: {
-          callbacks: {
-            title: (tooltipItem) =>
-              moment(tooltipItem[0].xLabel, "YYYY-MM-DD").format("LL"),
+        plugins: {
+          tooltip: {
+            callbacks: {
+              title: (tooltipItem) =>
+                moment(tooltipItem[0].label, "YYYY-MM-DD").format("LL"),
+            },
+          },
+          legend: {
+            display: false,
           },
-        },
-        legend: {
-          display: false,
         },
         responsive: true,
         maintainAspectRatio: false,
@@ -136,15 +138,10 @@ export default Component.extend({
           },
         },
         scales: {
-          yAxes: [
+          y: [
             {
               display: true,
               ticks: {
-                userCallback: (label) => {
-                  if (Math.floor(label) === label) {
-                    return label;
-                  }
-                },
                 callback: (label) => number(label),
                 sampleSize: 5,
                 maxRotation: 25,
@@ -152,7 +149,7 @@ export default Component.extend({
               },
             },
           ],
-          xAxes: [
+          x: [
             {
               display: true,
               gridLines: { display: false },
diff --git a/app/assets/javascripts/admin/addon/components/admin-report-stacked-chart.js b/app/assets/javascripts/admin/addon/components/admin-report-stacked-chart.js
index 4c3a9bb..d94d6c3 100644
--- a/app/assets/javascripts/admin/addon/components/admin-report-stacked-chart.js
+++ b/app/assets/javascripts/admin/addon/components/admin-report-stacked-chart.js
@@ -89,21 +89,24 @@ export default Component.extend({
         animation: {
           duration: 0,
         },
-        tooltips: {
-          mode: "index",
-          intersect: false,
-          callbacks: {
-            beforeFooter: (tooltipItem) => {
-              let total = 0;
-              tooltipItem.forEach(
-                (item) => (total += parseInt(item.yLabel || 0, 10))
-              );
-              return `= ${total}`;
+        plugins: {
+          tooltip: {
+            mode: "index",
+            intersect: false,
+            callbacks: {
+              beforeFooter: (tooltipItem) => {
+                let total = 0;
+                tooltipItem.forEach(
+                  (item) => (total += parseInt(item.parsed.y || 0, 10))
+                );
+                return `= ${total}`;
+              },
+              title: (tooltipItem) =>
+                moment(tooltipItem[0].label, "YYYY-MM-DD").format("LL"),
             },
-            title: (tooltipItem) =>
-              moment(tooltipItem[0].xLabel, "YYYY-MM-DD").format("LL"),
           },
         },
+
         layout: {
           padding: {
             left: 0,
@@ -113,16 +116,11 @@ export default Component.extend({
           },
         },
         scales: {
-          yAxes: [
+          y: [
             {
               stacked: true,
               display: true,
               ticks: {
-                userCallback: (label) => {
-                  if (Math.floor(label) === label) {
-                    return label;
-                  }
-                },
                 callback: (label) => number(label),
                 sampleSize: 5,
                 maxRotation: 25,
@@ -130,8 +128,7 @@ export default Component.extend({
               },
             },
           ],
-
-          xAxes: [
+          x: [
             {
               display: true,
               gridLines: { display: false },
diff --git a/app/assets/javascripts/discourse/app/lib/public-js-versions.js b/app/assets/javascripts/discourse/app/lib/public-js-versions.js
index 8ec9568..f3bb8cd 100644
--- a/app/assets/javascripts/discourse/app/lib/public-js-versions.js
+++ b/app/assets/javascripts/discourse/app/lib/public-js-versions.js
@@ -4,9 +4,9 @@
 export const PUBLIC_JS_VERSIONS = {
   "ace/ace.js": "ace.js/1.4.12/ace.js",
   "jsoneditor.js": "@json-editor/json-editor/2.5.2/jsoneditor.js",
-  "Chart.min.js": "chart.js/2.9.4/Chart.min.js",
+  "Chart.min.js": "chart.js/3.5.1/Chart.min.js",
   "chartjs-plugin-datalabels.min.js":
-    "chartjs-plugin-datalabels/0.7.0/chartjs-plugin-datalabels.min.js",
+    "chartjs-plugin-datalabels/2.0.0/chartjs-plugin-datalabels.min.js",
   "diffhtml.min.js": "diffhtml/1.0.0-beta.18/diffhtml.min.js",
   "jquery.magnific-popup.min.js":
     "magnific-popup/1.1.0/jquery.magnific-popup.min.js",
diff --git a/app/assets/javascripts/discourse/tests/acceptance/admin-search-log-term-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-search-log-term-test.js
index a1d472a..078676b 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/admin-search-log-term-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/admin-search-log-term-test.js
@@ -9,7 +9,7 @@ acceptance("Admin - Search Log Term", function (needs) {
     await visit("/admin/logs/search_logs/term?term=ruby");
 
     assert.ok(exists(".search-logs-filter"), "has the search type filter");
-    assert.ok(exists("canvas.chartjs-render-monitor"), "has graph canvas");
+    assert.ok(exists("canvas"), "has graph canvas");
     assert.ok(exists("div.header-search-results"), "has header search results");
   });
 });
diff --git a/package.json b/package.json
index abcdfe6..6f3994f 100644
--- a/package.json
+++ b/package.json
@@ -19,8 +19,8 @@
     "blueimp-file-upload": "10.13.0",
     "bootbox": "3.2.0",
     "bootstrap": "v3.4.1",
-    "chart.js": "2.9.4",
-    "chartjs-plugin-datalabels": "^0.7.0",
+    "chart.js": "3.5.1",
+    "chartjs-plugin-datalabels": "^2.0.0",
     "diffhtml": "^1.0.0-beta.18",
     "eslint-config-discourse": "^1.1.8",
     "handlebars": "^4.7.7",
diff --git a/plugins/poll/assets/javascripts/components/poll-breakdown-chart.js.es6 b/plugins/poll/assets/javascripts/components/poll-breakdown-chart.js.es6
index be78266..20ec3b2 100644
--- a/plugins/poll/assets/javascripts/components/poll-breakdown-chart.js.es6
+++ b/plugins/poll/assets/javascripts/components/poll-breakdown-chart.js.es6
@@ -5,6 +5,7 @@ import discourseComputed from "discourse-common/utils/decorators";
 import { getColors } from "discourse/plugins/poll/lib/chart-colors";
 import { htmlSafe } from "@ember/template";
 import { mapBy } from "@ember/object/computed";
+import { next } from "@ember/runloop";
 
 export default Component.extend({
   // Arguments:
@@ -92,6 +93,7 @@ export default Component.extend({
       },
       options: {
         plugins: {
+          tooltip: false,
           datalabels: {
             color: "#333",

[... diff too long, it was truncated ...]

GitHub sha: d7c185bf3d8810bb4379d0081cdd312002c10209

This commit appears in #14107 which was approved by CvX. It was merged by jjaffeux.