<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Format Panel Toggle Switch to Reveal More Options in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Format-Panel-Toggle-Switch-to-Reveal-More-Options/m-p/973830#M22681</link>
    <description>&lt;P&gt;In a custom visual, is it possible to create a sub-section in the format panel that will appear or disappear when a toggle is switched?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, in the standard bar chart visual under the "Data Labels Section" there is a "show background" option.&amp;nbsp;&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Capture.PNG" style="width: 112px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/246105i92F49A3E6CDFB75E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;When you click on that it causes several more options to appear that weren't previously there:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Capture(2).PNG" style="width: 169px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/246104i9BD40A92C4803851/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture(2).PNG" alt="Capture(2).PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to duplicate this on a custom visual.&amp;nbsp; I tried modifying the capabilities file in all different ways (especially using the show function) but couldn't figure it out.&amp;nbsp; Any suggestions?&lt;/P&gt;&lt;P class="ics-element-donot-delete 1001_CC@"&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 13 Mar 2020 18:52:15 GMT</pubDate>
    <dc:creator>cogsie</dc:creator>
    <dc:date>2020-03-13T18:52:15Z</dc:date>
    <item>
      <title>Format Panel Toggle Switch to Reveal More Options</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Format-Panel-Toggle-Switch-to-Reveal-More-Options/m-p/973830#M22681</link>
      <description>&lt;P&gt;In a custom visual, is it possible to create a sub-section in the format panel that will appear or disappear when a toggle is switched?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, in the standard bar chart visual under the "Data Labels Section" there is a "show background" option.&amp;nbsp;&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Capture.PNG" style="width: 112px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/246105i92F49A3E6CDFB75E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;When you click on that it causes several more options to appear that weren't previously there:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Capture(2).PNG" style="width: 169px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/246104i9BD40A92C4803851/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture(2).PNG" alt="Capture(2).PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to duplicate this on a custom visual.&amp;nbsp; I tried modifying the capabilities file in all different ways (especially using the show function) but couldn't figure it out.&amp;nbsp; Any suggestions?&lt;/P&gt;&lt;P class="ics-element-donot-delete 1001_CC@"&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2020 18:52:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Format-Panel-Toggle-Switch-to-Reveal-More-Options/m-p/973830#M22681</guid>
      <dc:creator>cogsie</dc:creator>
      <dc:date>2020-03-13T18:52:15Z</dc:date>
    </item>
    <item>
      <title>Re: Format Panel Toggle Switch to Reveal More Options</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Format-Panel-Toggle-Switch-to-Reveal-More-Options/m-p/973891#M22684</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/175974"&gt;@cogsie&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;The way this works is by elmination:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Properties have to exist in the visual capabilities first.&lt;/LI&gt;
&lt;LI&gt;They can be removed from view in your object enumeration logic.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;You can get quite creative with it, but I'll provide a simple example.&lt;/P&gt;
&lt;P&gt;First ensure that your objects are all configured up in your &lt;FONT face="courier new,courier"&gt;capabilities.json&lt;/FONT&gt; and they have a corresponding setting object so that they appear in the pane.&lt;/P&gt;
&lt;P&gt;If we start with a new visual, I've added these to the capabilities under the &lt;FONT face="courier new,courier"&gt;dataPoint&lt;/FONT&gt; object:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;"toggle": {
    "displayName": "Show my Property",
    "type": {
        "bool": true
    }
},
"hideOnToggle": {
    "displayName": "I Get Hidden if This Works",
    "type": {
        "text": true
    }
}&lt;/LI-CODE&gt;
&lt;P&gt;I'll add a couple of extra properties to the &lt;FONT face="courier new,courier"&gt;dataPointSettings&lt;/FONT&gt; class in &lt;FONT face="courier new,courier"&gt;settings.ts&lt;/FONT&gt;, e.g.:&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;      ...
      // Test toggle
      public toggle: boolean = true;
      // Should hide if toggle off
      public hideOnToggle: string = 'Hiya!';
   }&lt;/LI-CODE&gt;
&lt;P&gt;These should now show up in my properties pane, e.g.:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 208px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/246110i0427C953DBF6DC57/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I'll now wire-up my logic.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;You can then change &lt;FONT face="courier new,courier"&gt;enumerateObjectInstances&lt;/FONT&gt; in &lt;FONT face="courier new,courier"&gt;visual.ts&lt;/FONT&gt; to manipulate the object that gets returned to the properties pane.&lt;/LI&gt;
&lt;LI&gt;This runs once for every menu in the pane that you have configured, so you need to check which one is currently being processed and handle accordingly.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;To make this easier we can change the function a little bit. Assuming you're starting with the one that gets generated, first change its signature to:&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;    public enumerateObjectInstances(
        options: EnumerateVisualObjectInstancesOptions
    &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; VisualObjectInstance[] {

        const instances: VisualObjectInstance[] = (
            VisualSettings.enumerateObjectInstances(
                this.settings || VisualSettings.getDefault(),
                options
            ) as VisualObjectInstanceEnumerationObject).instances;
        
        return instances;

    }&lt;/LI-CODE&gt;
&lt;P&gt;This gets the same result as before, but exposes the current instance being processed, so that you can manipulate it. We'll now add some logic to process the pane, e.g.:&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;    public enumerateObjectInstances(
        options: EnumerateVisualObjectInstancesOptions
    &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; VisualObjectInstance[] {

        const instances: VisualObjectInstance[] = (
            VisualSettings.enumerateObjectInstances(
                this.settings || VisualSettings.getDefault(),
                options
            ) as VisualObjectInstanceEnumerationObject).instances;
        
        /** 
         * This will be the name of our current menu and will match the 
         * object name from capabilities
         */
            let objectName = options.objectName;

        /**
         * Process the object, based on which one it is
         */
            switch (objectName) {

                case 'dataPoint': {
                    /**
                     * Handle toggle of our text field by removing it from view.
                     */
                        if (!this.settings.dataPoint.toggle) {
                            delete instances[0].properties['hideOnToggle'];
                        }
                        break;
                }

                /** Add logic for additional menus underneath as needed */

            }

        return instances;

    }&lt;/LI-CODE&gt;
&lt;P&gt;This will now remove the text box when we toggle to false and leave it in as intended when we toggle to true, e.g.:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Property Toggle.gif" style="width: 196px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/246115i02BAEEB30B88A07C/image-size/large?v=v2&amp;amp;px=999" role="button" title="Property Toggle.gif" alt="Property Toggle.gif" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Note that this &lt;STRONG&gt;does not change the actual settings&lt;/STRONG&gt; in the visual and simply manages what gets returned to the main window to present to the user. You can still access the underlying settings for the hidden items in your visual logic and you need to plan for this in some cases.&lt;/P&gt;
&lt;P&gt;For example, if our text field has some influence on our visual (e.g. a displayed label), then you would need to handle what happens if the toggle is off, so that the underlying value does not get shown anyway.&lt;/P&gt;
&lt;P&gt;As mentioned above, you can get very creative with this and can use a number of different conditions, and also use properties in one menu to hide those in another. If you check the source of other custom visuals you should be able to see examples of how other authors are doing it.&lt;/P&gt;
&lt;P&gt;I hope this gets you moving. Good luck!&lt;/P&gt;
&lt;P&gt;Daniel&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2020 19:51:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Format-Panel-Toggle-Switch-to-Reveal-More-Options/m-p/973891#M22684</guid>
      <dc:creator>dm-p</dc:creator>
      <dc:date>2020-03-13T19:51:15Z</dc:date>
    </item>
    <item>
      <title>Re: Format Panel Toggle Switch to Reveal More Options</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Format-Panel-Toggle-Switch-to-Reveal-More-Options/m-p/973963#M22687</link>
      <description>&lt;P&gt;That worked perfectly.&amp;nbsp; I was trying to tinker around with the settings.ts file, but obviously that was not working.&amp;nbsp; I would never have figured this out.&amp;nbsp; Thanks for the help.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2020 20:43:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Format-Panel-Toggle-Switch-to-Reveal-More-Options/m-p/973963#M22687</guid>
      <dc:creator>cogsie</dc:creator>
      <dc:date>2020-03-13T20:43:50Z</dc:date>
    </item>
    <item>
      <title>Re: Format Panel Toggle Switch to Reveal More Options</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Format-Panel-Toggle-Switch-to-Reveal-More-Options/m-p/973972#M22688</link>
      <description>No worries - it's not intuitive at all so if I can save at least one person the majority of the time it took me, then that's a win in my book!</description>
      <pubDate>Fri, 13 Mar 2020 20:47:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Format-Panel-Toggle-Switch-to-Reveal-More-Options/m-p/973972#M22688</guid>
      <dc:creator>dm-p</dc:creator>
      <dc:date>2020-03-13T20:47:24Z</dc:date>
    </item>
  </channel>
</rss>

