Forum Discussion
Custom Visual Objects Migration & Report Page Tooltip Properties
- 7 years ago
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
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 :)
Thanks again,
Daniel
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
- dm-p7 years agoSuper User
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-p7 years agoSuper User
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!