KoolReport's Forum

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

Javascript errors on barchart #528

Open Alex Chartier opened this topic on on Nov 22, 2018 - 7 comments

Alex Chartier commented on Nov 22, 2018

I am trying to use the tutorial 1 scripts. The table works fine but the barchart does not display. I am getting 2 javascript errors in the console. I include a screengrab of the errors.

Any ideas?

KoolReport commented on Nov 22, 2018

Let try to add this to your report to see how:

class SalesByCustomer extends \koolreport\KoolReport
{
    use \koolreport\clients\jQuery;

}

Or better you can use \koolreport\clients\Bootstrap;

Please let us know.

Alex Chartier commented on Nov 22, 2018

jQuery worked, Bootstrap did not. Thanks.

Leho Kraav commented on Feb 12, 2019

Hi.

We should be able to use our existing jQuery instance, instead of loading this double.

But this would require wrapping all KoolReport careless usages of $ variable into proper form:

(function($) {
  ...
} )(jQuery || {});

For example, DrillDown package is full of unguarded $ usage.

Your thoughts?

KoolReport commented on Feb 13, 2019

Actually if you see the rendered code of any widget, you will see that the widget will trying to get jquery and until jquery is on the page, then a callback function will be called to initiate the widgets. If the jquery is presented then the script will run immediately. This does not require you to even add the jQuery on report. However, you may add jQuery to make sure.

This new loading method in KoolReport open the chance that you may use any widgets of KoolReport in your application even without setting up a report. For example, in laravel view template, you may just call google chart widget and enter the Collections to dataSource, the chart will show and fully function.

Leho Kraav commented on Feb 13, 2019

Hrm, well on 3.21.0 yesterday, our drilldown charts failed w/ undefined $, and we load jQuery 1.12 in header.

We had to inject ugly $ = jQuery; stuff right before chart render function, now things work again.

I will test new release today.

KoolReport commented on Feb 13, 2019

Is it possible that you could upgrade jQuery to 3.x? Since the $ may not be defined in version 1.12

Leho Kraav commented on Feb 13, 2019

WordPress core specifically sets jQuery.noConflict() as platform default, since many many years ago. $ not existing is OK and expected.

AFAICS there's a relatively simple and safe path to handling both scenarios in KoolReport, as I described above (wrap into closures). Other than work time associated, is there any technical reason why it couldn't happen?

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
None yet

None