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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
janstrbik
Regular Visitor

Custom tooltip - Uncaught TypeError: Cannot read properties of null (reading 'hasIdentity')

I am developing custom simple visual where I would like to use built-in tooltips, I integrated it by documentation steps, but I am getting console error 

janstrbik_0-1639472149997.png

what is pointing to customVisualHost bundle where it looks like event is null in this method

janstrbik_1-1639472204718.png

and I have no clue what am I doing wrong. I prepared separate repository just with tooltip functionality.

 

https://github.com/janstrbik/PowerBI-custom-visual-tooltip

 

Can anyone help me out here? 

Thanks. Jan

1 ACCEPTED SOLUTION
dm-p
Super User
Super User

Hi @janstrbik, and thanks so much for providing a complete repo - super easy to start having a look around 🙂

The "issue" is on line 51, where you are passing the third parameter (selector):

 

    private renderTooltip() {
        this.tooltipServiceWrapper.addTooltip(
            d3.select(this.target),
            (tooltipEvent: tooltip.TooltipEventArgs<number>) => this.getTooltipData(),
            (tooltipEvent: tooltip.TooltipEventArgs<number>) => null); /** <--- right here */
    }

 

Modify this to an empty array, e.g.:

 

    private renderTooltip() {
        this.tooltipServiceWrapper.addTooltip(
            d3.select(this.target),
            (tooltipEvent: tooltip.TooltipEventArgs<number>) => this.getTooltipData(),
            (tooltipEvent: tooltip.TooltipEventArgs<number>) => []); /** <--- right here */
    }

 

This will now work as expected, e.g.:

dmp_0-1639519180039.png

Based on the typings, I think your approach is correct and there is an issue in the utilities somewhere (based on what looks like changes made to explicitly remove this restriction in the repo a while back.) This should apparently not need to be an array - report page tooltips only support a single selector.

I don't personally use this package in my projects (I usually use the visual host directly) so haven't come across this issue - you might want to raise this as an issue in the repo for the team to look at or provide an official response (giving them a link to your repo as a means of reproducing; it's quite clear in helping to illustrate what I think is incorrect here).

Either way, the above resolution should get you moving. If you do get to the point of passing in a selection ID for a report page tooltip here, I assume this would also need to be a single element array, so bear this in mind if/when you get there.

Good luck!

Daniel

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




View solution in original post

1 REPLY 1
dm-p
Super User
Super User

Hi @janstrbik, and thanks so much for providing a complete repo - super easy to start having a look around 🙂

The "issue" is on line 51, where you are passing the third parameter (selector):

 

    private renderTooltip() {
        this.tooltipServiceWrapper.addTooltip(
            d3.select(this.target),
            (tooltipEvent: tooltip.TooltipEventArgs<number>) => this.getTooltipData(),
            (tooltipEvent: tooltip.TooltipEventArgs<number>) => null); /** <--- right here */
    }

 

Modify this to an empty array, e.g.:

 

    private renderTooltip() {
        this.tooltipServiceWrapper.addTooltip(
            d3.select(this.target),
            (tooltipEvent: tooltip.TooltipEventArgs<number>) => this.getTooltipData(),
            (tooltipEvent: tooltip.TooltipEventArgs<number>) => []); /** <--- right here */
    }

 

This will now work as expected, e.g.:

dmp_0-1639519180039.png

Based on the typings, I think your approach is correct and there is an issue in the utilities somewhere (based on what looks like changes made to explicitly remove this restriction in the repo a while back.) This should apparently not need to be an array - report page tooltips only support a single selector.

I don't personally use this package in my projects (I usually use the visual host directly) so haven't come across this issue - you might want to raise this as an issue in the repo for the team to look at or provide an official response (giving them a link to your repo as a means of reproducing; it's quite clear in helping to illustrate what I think is incorrect here).

Either way, the above resolution should get you moving. If you do get to the point of passing in a selection ID for a report page tooltip here, I assume this would also need to be a single element array, so bear this in mind if/when you get there.

Good luck!

Daniel

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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