Forum Discussion

dm-p's avatar
dm-p
Super User
7 years ago
Solved

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 :smileyhappy:

 

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.
  • 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

    [email protected]

5 Replies

  • v-viig's avatar
    v-viig
    Community Champion

    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

    [email protected]

    • dm-p's avatar
      dm-p
      Super User

      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

      • v-viig's avatar
        v-viig
        Community Champion

        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

        [email protected]