Embed Javascript chart through JSAPI

Abhijeet Teli shared this problem 7 years ago
Resolved

HI Team,

While browsing through the changelogs of 73Plus i found below change in June EOM build

5871 - Added Javascript Chart support to the Javascript API


So to test this i have created a simple JavaScript chart and trying to embed it a plain HTML, The report got loaded but chart is not coming up and i am getting below error on console,


Uncaught ReferenceError: require is not defined
    at generateChart (eval at reportLoaded (JsAPI?cmd=loadreport&reportUUID=791a8ffa-f883-4ebf-9760-e1bcc17cc812&clientOrg=bmc&username=ateli@b…:1407), <anonymous>:9:1)
    at JSChart60919 (eval at reportLoaded (JsAPI?cmd=loadreport&reportUUID=791a8ffa-f883-4ebf-9760-e1bcc17cc812&clientOrg=bmc&username=ateli@b…:1407), <anonymous>:149:1)
    at eval (eval at reportLoaded (JsAPI?cmd=loadreport&reportUUID=791a8ffa-f883-4ebf-9760-e1bcc17cc812&clientOrg=bmc&username=ateli@b…:1407), <anonymous>:151:1)
    at Object.reportLoaded (JsAPI?cmd=loadreport&reportUUID=791a8ffa-f883-4ebf-9760-e1bcc17cc812&clientOrg=bmc&username=ateli@b…:1407)
    at vw-pun-atm-dv37:9191/JsAPI?api=reports&cmd=loadReport&reqId=1&version=2.1&r…rue&clientOrg=bmc&u=283334821:1
net::ERR_CONNECTION_REFUSED
requirejs.js Failed to load resource: net::ERR_CONNECTION_REFUSED

Essentially its indicating requirejs is missing not sure where else i need to define require js statement, My report is working fine in Yellowfin UI,


I am using Yellowfin 73+ (20170608)


Please let me know if i am Missing something


Thanks,

Abhijeet

Best Answer
photo

Yes Nathan,

That's correct, it worked after updating "External Base URL"


Thanks,

Abhijeet

Replies (6)

photo
1

Hi Abhijeet,


It looks like this was not actually fixed in time for the 20170608 release (I was not able to embed this in my tests either, though with a different error). Our JIRA ticket has this labelled as fixed for the June EOM release (0630) so I believe that this will be included in the next patch, which will be released tonight.


I will test this tomorrow, but please let me know if you are still facing trouble as well.


Regards,

Nathan

photo
1

Hi Nathan,

I Have upgraded my environment with latest environment but still i am getting exact same error, So i don't think so it was build issue,

But good news is i figured out how this can be achieved.

Issue was related to some javascript references we have used while creating js charts in yellowfin are not directly accessible or valid from browser/client side, and Yellowfin jsAPI is dumping entire javascript on client and trying to access those from browser, which was causing issues

In my case there were two issues.

require() - we use require function to link external charting libraries but require function is only accessible from server end. So i have added require.js script on my server to handle this dependency in my browser then added reference to this .js in my Plain html page where i am embedding the chart, require is an open source javascript and module loader.

<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.js" type="text/javascript"></script> 

Uncaught ReferenceError: $ is not defined

This one is again jquery related server side dependency so need to resolve this on s well, with CDN or local reference to load jquery js file


<script src="https://code.jquery.com/jquery-3.2.1.min.js"; type="text/javascript"></script>  
and Bingoooo, I got my chart loaded.

Thanks,

Abhijeet

photo
1

Hi Abhijeet,


Excellent find! I have been able to confirm this and raised a defect ticket to address it.


Since there is an open source CDN for require I have edited your post to use this (so you dont have to DL the module in the meantime).


Regards,

Nathan

photo
1

Hi Abhijeet,


Turns out all you need to do here is to set your "External Base URL" in the configuration section of the admin console.


Let me know if this works for you as well.


Regards,

Nathan

photo
1

Yes Nathan,

That's correct, it worked after updating "External Base URL"


Thanks,

Abhijeet

photo
1

Hi Abhijeet,


Glad to hear it. I am going to switch your response to best answer so any other clients facing this issue can see it first :)


Regards,

Nathan

Leave a Comment
 
Attach a file