Forum Discussion
Custom Visual Tooltip to show the Tooltip page
- 7 years ago
Hi Anonymous,
if you're just using a measure, then you'd use the .withMeasure() function when creating.
I have created a branch in my sample repo for the card, with a commit detailing all changes I made to get this to work. You should be able to check this branch out and have a look.
The selection ID will work from the measure field; the tooltips field is not used in this case, so you may need to amend your approach as required.
Changes should be highlighted in the commit details, but to summarise what I did:
- Created a measureSelectionId property in my ICard interface
- Assigned the host object as a visual class property
- Added this to the view model function call signature, and updated this in the visual workflow
- Set this to null before we validate the view model
- Create a selection ID for the measure if the visual state is valid
- Add this to the third function parameter for the addTooltip call
I created a report page with the same measure on it, e.g.:
Added Length (mm) measure as report page tooltip filter
I set up the tooltip page as normal, e.g.:
Assigning tooltip page
Going back to the data roles, I'll now see that the Tooltip Page is showing in the Tooltip role:
So far, so good...
And, if I hover over, I get my page, e.g.:
Success!But... there's more! Even though this is a single measure, note that my report page has a column chart for a breakdown by category. Even though I only specify .withMeasure() in my createSelectionIdBuilder() call, the selection ID is smart enough to know that if I filter my visual by the category above (e.g. removing 0.5), then the report page will filter it out too, e.g.:Category filtering at visual level respected by report page tooltip
Hopefully this helps you out with your challenge.
Good luck!
Daniel
Thank you dm-p for spotting out the problem.
I went through the sample barchart example (not 100% I follow that selectionID definition though). My custom visual is a simple KPI card with a value displayed as a text svg element (like your difinity 2019 example), it seems in order to get the selectionID done with this, I need to modify quite a bit of my viewmodel, e.g. creating new class etc. If modifying my simple viewmodel into a complicated one like the sample barchart/violin is the only way, I'll do it. But I wonder how I can just add a simple selectionID onto my svg text value?
Thanks again.
Hi Anonymous,
if you're just using a measure, then you'd use the .withMeasure() function when creating.
I have created a branch in my sample repo for the card, with a commit detailing all changes I made to get this to work. You should be able to check this branch out and have a look.
The selection ID will work from the measure field; the tooltips field is not used in this case, so you may need to amend your approach as required.
Changes should be highlighted in the commit details, but to summarise what I did:
- Created a measureSelectionId property in my ICard interface
- Assigned the host object as a visual class property
- Added this to the view model function call signature, and updated this in the visual workflow
- Set this to null before we validate the view model
- Create a selection ID for the measure if the visual state is valid
- Add this to the third function parameter for the addTooltip call
I created a report page with the same measure on it, e.g.:
Added Length (mm) measure as report page tooltip filter
I set up the tooltip page as normal, e.g.:
Assigning tooltip page
Going back to the data roles, I'll now see that the Tooltip Page is showing in the Tooltip role:
So far, so good...
And, if I hover over, I get my page, e.g.:
Success!But... there's more! Even though this is a single measure, note that my report page has a column chart for a breakdown by category. Even though I only specify .withMeasure() in my createSelectionIdBuilder() call, the selection ID is smart enough to know that if I filter my visual by the category above (e.g. removing 0.5), then the report page will filter it out too, e.g.:Category filtering at visual level respected by report page tooltip
Hopefully this helps you out with your challenge.
Good luck!
Daniel
- Anonymous7 years agoNot applicable
Thanks dm-p
Thank you so much for the detailed explanation and example. I will modify my interface with selectionID too.
- Anonymous6 years agoNot applicable
Hello,
I'm facing a very similar problem.
Can you please share the repository?
I really appreciate it, thank you.
Anonymous wrote:Thanks dm-p
Thank you so much for the detailed explanation and example. I will modify my interface with selectionID too.
Anonymous wrote:Thanks dm-p
Thank you so much for the detailed explanation and example. I will modify my interface with selectionID too.
- dm-p6 years ago
Super User
Hi Anonymous,
The repo link is in the post marked as the solution, albeit direct links to the branch and commit of interest.
The specifc repo link is here. Note that as per the links above, the example is in a branch off master named report-page-tooltip, so once you have cloned the repo you will need to check out this branch specifically to observe the changes documented above.
Good luck!
Daniel