KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Datalabels (chartjs) not compatible with Cloud Export (chromium) #2630

Open Thomas opened this topic on on Apr 5, 2022 - 8 comments

Thomas commented on Apr 5, 2022

When I activate datalabels in ChartJS than the charts doesn't show up in the cloud export (sometimes only the first). *. "plugins"=>array("annotation","datalabels"),

In the browser they show up, but not every time. Sometimes I have to refresh the page.

Consol log Output, that could be related to that issue: . chartjs-plugin-datalabels1. :7 Uncaught TypeError: Cannot read properties of undefined (reading 'helpers') . [Violation] 'load' handler took 179ms *. [Violation] 'requestAnimationFrame' handler took 75ms (Chart.bundle.min.js:7)

I've tried every configuration: *. "pageWaiting"=>"networkidle0", // load, domcontentloaded, networkidle0, networkidle2

This is also happening with the internal puppeteer export.

What can I do to make it work?

Sebastian Morales commented on Apr 5, 2022

Pls try to download chartjs' datalabels version 1.0.0 from this release:

https://github.com/chartjs/chartjs-plugin-datalabels/releases/tag/v1.0.0

and replace the file koolreport/chartjs/chartjs-plugin-datalabels.min.js with version 1.0.0. Then check the console of your chartjs report page to see if uncaught TypeError remains. Tks,

Thomas commented on Apr 5, 2022

The uncaught TypeError does not show but only the first chart is shown in the cloud export and none in the serverside chromium export.

When I erase all datalabels and other options ("options"=>array(...) and only leave the plugin line, than the error still occurs.

When I comment the line (//"plugins"=>array("datalabels"),) out, than all charts are shown but without the datalabels.

What else can I try?

Thomas commented on Apr 5, 2022

I've noticed on an other report, that the "Uncaught TypeError: Cannot read properties of undefined (reading 'helpers')" appears after I filter and refresh the page.

Thomas commented on Apr 5, 2022

On the current project the error doesn't show on the second load. If I force the page to load from scratch, than the error appears.

I've also tried the 2.0 version of the data labels plugin and the error is persistant. The browser shows no charts like the the export.

Thomas commented on Apr 5, 2022

I am not sure if this is an koolreport related issue or not.

If I use the the chartjs in a script with the cdn files directly, than the export shows the chart and the datalabels. But still not the koolreport charts.

I've took the raw koolreport chart from the created html file in the tmp folder and inserted it into my report view. With the following code, the charts are shown finally:

<script type="text/javascript">
KoolReport.widget.init({"js":["https:\/\/...\/vendor\/koolreport\/chartjs\/clients\/Chart.bundle.min.js","https:\/\/...\/vendor\/koolreport\/chartjs\/clients\/chartjs.js","https:\/\/...\/vendor\/koolreport\/chartjs\/clients\/chartjs-plugin-annotation.min.js","https:\/\/...\/vendor\/koolreport\/chartjs\/clients\/chartjs-plugin-datalabels.min.js"],"css":[]},function(){});
</script>

I don't know if this is related to an other topic (https://www.koolreport.com/forum/topics/1674), in which I had to change the recoursemanager to make the internal chromium export to work.

$protocol = isset($_SERVER['HTTPS']) && (strcasecmp($_SERVER['HTTPS'], 'on')===0 || $_SERVER['HTTPS']==1)
        || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strcasecmp($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https')===0 ? "https" : "http";
        $http_host = (!empty($_SERVER['HTTP_HOST']))?"$protocol://".$_SERVER['HTTP_HOST']:"http://localhost";
        $assetUrl = $http_host . $assetUrl;
        return $assetUrl;
Sebastian Morales commented on Apr 6, 2022

If you make change to ResourceManager.php like described in topic https://www.koolreport.com/forum/topics/1674 does chartjs with datalabels works with cloud export?

Thomas commented on Apr 6, 2022

Actually, the changes in the resource manager has no effect on the cloud export. I've tested the default configuration and with the change and in bot cases the export doesn't show the charts or sometimes only the first.

With the above KoolReport.widget.init script at the beginning of the body it is working at least on the serverside chromium export now.

Sebastian Morales commented on Apr 6, 2022

Can you pls setup an online link to your report page and email it to support@koolreport.com / support@koolphp.net for us to investigate it directly. Pls attach your report's setup and view code as well. Tks,

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

None