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.
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
This has given me a few challenges to rexolve and I'd be really grateful if anyone has any ideas:
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)
Solved! Go to Solution.
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 @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
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)
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
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
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)
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!
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)
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
17 | |
2 | |
2 | |
1 | |
1 |