cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dm-p Member
Member

Custom Visual Objects Migration & Report Page Tooltip Properties

Hi there,

 

I'm just looking at updating one of my custom visuals to allow the use of report page tooltips, and while I can get this working just fine, I've realised that I need to fix my existing Tooltip menu functionality in order to unify the behaviour.

 

Currently, my Tooltip menu is defined using an object named tooltip. As a result, when I add in the report page tooltip functionality, I get two Tooltip menus in the properties pane, e.g.:

 

 

Through some investigation, I've found that the standard Tooltip menu is internally named visualTooltip, and if I define my object and VisualSettings accordingly, I get a single Tooltip menu as expected Smiley Happy

 

This has given me a few challenges to rexolve and I'd be really grateful if anyone has any ideas:

 

  1. Now that I've changed my object name, and existing metadata.objects.tooltip property settings in a user's report are no longer applied and would need to be re-pointed to visualTooltip. I'd like to try and do this without the user losing their existing properties. I had thought about using persistObjectProperties in the update method by grabbing existing tooltip properties and merging them into visualTooltip, but they seem to be lost before I get to this point. Is there a recommended approach for migrations of this kind, or do I need to treat this is a breaking change?
  2. The report page properties, Type and Page, are placed at the bottom of the merged Tooltip menu. is it possible to reposition them by declaring them in my capabilities/settings.ts or extending an existing class? I'd ideally like them to be positioned at the top and the framework seems to prioritise my custom properties over the in-built ones.
  3. Is it possible to get access to the values of the Type and Page properties? They do not seem to be available when I inspect in enumerateObjectInstances. This is primarily to allow me to manage the show/hide of my custom properties if the user opts not to show the tooltip page and use the previous tooltip functionality.
1 ACCEPTED SOLUTION

Accepted Solutions
Moderator v-viig
Moderator

Re: Custom Visual Objects Migration & Report Page Tooltip Properties

Hi @dm-p ,

 

The predefined properties can't be controlled from Custom Visuals. That means you can not change order and you can not get their values.

 

To keep backward compatibility you should keep both tooltip and visualTooltip in the capabilities.json. It's required to get tooltip options in legacy reports.

 

EnumerateObjectInstances should return an empty array for the tooltip to hide it in Format Panel.

 

As a third step, you should update Settings parse to check visualTooltip first. It's defined you should ignore values from the tooltip. Otherwise, you should copy tooltip to visualTooltip in your Settings parser.

 

Let me know if you have any questions.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

5 REPLIES 5
Moderator v-viig
Moderator

Re: Custom Visual Objects Migration & Report Page Tooltip Properties

Hi @dm-p ,

 

The predefined properties can't be controlled from Custom Visuals. That means you can not change order and you can not get their values.

 

To keep backward compatibility you should keep both tooltip and visualTooltip in the capabilities.json. It's required to get tooltip options in legacy reports.

 

EnumerateObjectInstances should return an empty array for the tooltip to hide it in Format Panel.

 

As a third step, you should update Settings parse to check visualTooltip first. It's defined you should ignore values from the tooltip. Otherwise, you should copy tooltip to visualTooltip in your Settings parser.

 

Let me know if you have any questions.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

dm-p Member
Member

Re: Custom Visual Objects Migration & Report Page Tooltip Properties

Hi @v-viig , and thanks once again for the prompt response and detailed reply.

 

This works great, but just a little bit stuck on step #3 of your solution - I can swap out the dataView when parsing settings but this is passive and I can't get it to persist into the visual settings. This means that when I upgrade the visual, all settings are preserved (properties pane looks correct etc.), but when I make a change, it will switch to the defaults and then apply the one I just changed, throwing away the previous values. I suspect that this is just how I'm working with the dataView and my understanding of its persistence.

 

Here's what I'm currently doing:

 

private static parseSettings(dataView: DataView): VisualSettings {

    /** #57: Migrate the old `tooltip` into `visualTooltip`, if required */
        if (    dataView.metadata
            &&  dataView.metadata.objects
            &&  dataView.metadata.objects.tooltip
            &&  !dataView.metadata.objects.visualTooltip
        ) {
            dataView.metadata.objects.visualTooltip = dataView.metadata.objects.tooltip;
        }

    return VisualSettings.parse(dataView) as VisualSettings;
}

How would I go about ensuring that these changes get persisted into the dataView rather than passively applied? I'm pretty sure that once I can get this bit sorted then I'm good to go Smiley Happy

 

Thanks again,

 

Daniel

Moderator v-viig
Moderator

Re: Custom Visual Objects Migration & Report Page Tooltip Properties

I suggest merging options:

dataView.metadata.objects.visualTooltip = {
...dataView.metadata.objects.tooltip,
...dataView.metadata.objects.visualTooltip,
};

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

dm-p Member
Member

Re: Custom Visual Objects Migration & Report Page Tooltip Properties

Cheers, @v-viig, and thanks for making me aware of spread syntax!

 

This is getting me pretty close to the end - one final sticking point: if I do a Revert to default in the visualTooltip properties pane, it will revert the settings to the copied tooltip properties, as the framework removes the visualTooltip from my objects, but the tooltip is left alone.

 

Is there an approach I can use to observe for this event and nullify the tooltip object accordingly if the visualTooltip is reverted? The VisualUpdateType that gets fired is type 2 (Data), so doesn't look like there's anything I can get from that.

 

Thanks again,

 

Daniel

dm-p Member
Member

Re: Custom Visual Objects Migration & Report Page Tooltip Properties

Ok... so this one's kind of resolved itself. Due to the introduction of the tooltip formatting changes in Power BI this month, I've opted to just enable the tooltip menus for this additional functionality and rename my existing tooltip menu as an additional set of properties. As I wasn't able to control the visibility of my tooltip menu objects based on the status of standard objects (i.e. whether the tooltip was being shown or not), it just seems easier for the end user this way. As a result, I don't need to handle migration of my objects from one key to another.

 

Thanks @v-viig for all your help though!