[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX] chartjs: Prevent fatal js errors with multiple charts on the same page.

"Jonny Bradley \(@jonnybradley\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <6a86f6f15ef63_38bb6d04504e6@gitlab-sidekiq-low-urgency-cpu-bound-v2-599d57f945-2g9zb.mail>

Jonny Bradley pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
f912d779 by Jonny Bradley at 2026-08-20T12:28:51+00:00
[FIX] chartjs: Prevent fatal js errors with multiple charts on the same page.
---
* [FIX] chartjs: Prevent fatal js errors with multiple charts on the same page.
Reverts most of !5155 (by me) which was needed a couple of years ago, but errors now.

See merge request tikiwiki/tiki!11013

- - - - -


1 changed file:

- lib/wiki-plugins/wikiplugin_chartjs.php


Changes:

=====================================
lib/wiki-plugins/wikiplugin_chartjs.php
=====================================
@@ -164,20 +164,13 @@ function wikiplugin_chartjs($data, $params)
     $canvas = '<canvas id="' . $params['id'] . '" width="' . $params['width'] . '" height="' . $params['height'] . '"></canvas>';
 
     if (! $to_PDF) {
-        if ($instance === 1) {
-            TikiLib::lib('header')->add_js_module(
-                '
-                import { Chart, registerables } from "chartjs";
-                Chart.register(...registerables);
-                setTimeout(function () {' . $script . '}, 500);
-             '
-            );
-        } else {
-            TikiLib::lib('header')->add_js_module('
-                setTimeout(function () {' . $script . '}, 500);
-             ');
-        }
-
+        TikiLib::lib('header')->add_js_module(
+            '
+            import { Chart, registerables } from "chartjs";
+            Chart.register(...registerables);
+            setTimeout(function () {' . $script . '}, 500);
+         '
+        );
         return '<div class="tiki-chartjs">' . $canvas . '</div>';
     }
 



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/f912d7791abc8cb950d6a9a231a4bb69bf8b326a

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/f912d7791abc8cb950d6a9a231a4bb69bf8b326a
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.