Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Tamil
Frequent Visitor

Issue in adding Library files in tsconfig

We have all library files loaded from a local host source.But I want those library function source to be added in ts config file.

So, I tried adding Jquery and Jquery UI custom libraries, which on execution it throw an error like UI not defined.

This error is not encountered when the same library files are directed to local host and added in the source file.

4 REPLIES 4
gdonnellan
Regular Visitor

This issue may be related to the sandboxing that is done on custom visual and I ran into the same issue myself and while I have a work around I am not sure if there is a better way of doing this.

 

When you include a custom library its bound to the window and not globally. jQuery for example would be window.jQuery or window.$. Also if you are using TypeScript you will run into the issue that window is strongly type and therefor jQuery will not be available as a property unless you redefine window as any type

 

public _window : any

_window = window;

 

_window.jQuery should now work.

 

  • JQuery - 2.2.0
  • d3 - 3.5.5

 should be loaded by default I assume in their correct name spaces so I dont know if you would need to do the above.

 

If you are missing the typings for jQuery UI that may also throw errors during build, the documentation should cover how to add typings to the project if they are available, if its a build error that is happening instead of a runtime error? 

 

Hello gdonnellan,

 

   I debug the visual.js file and all the default files,  but I didn't found anything.

   Can you please suggest me in which file I need to include this 

public _window : any

_window = window;

 

Thanks in advance,

Tamil

Add it in the main plugin .ts where you have implemented the IVisual interface. 

 

In my case I was working with different library from jQuery. it might be different with that one as its a bit of a special case like D3.js when it comes to custom visuals. Your problem may be related to not having the proper typings installed though for jQuery UI if its a compile time problem you are encountering.

 

export class NetworkVisual implements IVisual {
    private _window : any;

    constructor(options: VisualConstructorOptions) {

        this._window = window;

        debugger;

        // this._window.jQuery should be available

    }

}

Hello gdonnellan,

    Can you please provide with a sample screenshot/file for how to import the external library files in typescript .

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.