<?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 Re: getformattingmodel() implementation in Custom Visuals Development Discussion</title>
    <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/getformattingmodel-implementation/m-p/3427468#M7963</link>
    <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/397"&gt;@dm-p&lt;/a&gt;&amp;nbsp; for your quick response. While I used this.setting, it didn't work. So I have used&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;getFormattingModel&lt;/SPAN&gt;&lt;SPAN&gt;() for formatting and it and finally worked.&lt;BR /&gt;Thanks Again!&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Wed, 13 Sep 2023 02:56:50 GMT</pubDate>
    <dc:creator>AakashMarasini</dc:creator>
    <dc:date>2023-09-13T02:56:50Z</dc:date>
    <item>
      <title>getformattingmodel() implementation</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/getformattingmodel-implementation/m-p/3425439#M7955</link>
      <description>&lt;P&gt;Hi Developers!&lt;BR /&gt;&lt;BR /&gt;I am new at power bi custom visual development. I am trying to add formatting pane for x axis label. FrontEnd/UI part is displayed correctly in power bi. I am facing difficulties in binding the data to it.&lt;BR /&gt;code for getformattingModel() in visual.ts file&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;public getFormattingModel(): powerbi.visuals.FormattingModel {
  let dataCard: powerbi.visuals.FormattingCard = {
    description: "Data Card Description",
    displayName: "Axis Formatting",
    uid: "dataCard_uid",
    groups: [],
  };

  function createAxisFormattingGroup(displayName: string, uid: string): powerbi.visuals.FormattingGroup {
    return {
      displayName: displayName,
      uid: uid,
      slices: [
        {
          uid: "data_font_control_slice_uid",
          displayName: "Font",
          control: {
            type: powerbi.visuals.FormattingComponent.FontControl,
            properties: {
              fontFamily: {
                descriptor: {
                  objectName: "dataCard",
                  propertyName: "fontFamily",
                },
                value: "wf_standard-font, helvetica, arial, sans-serif",
              },
              fontSize: {
                descriptor: {
                  objectName: "dataCard",
                  propertyName: "fontSize",
                },
                value: 20,
              },
              bold: {
                descriptor: {
                  objectName: "dataCard",
                  propertyName: "fontBold",
                },
                value: false,
              },
              italic: {
                descriptor: {
                  objectName: "dataCard",
                  propertyName: "fontItalic",
                },
                value: false,
              },
              underline: {
                descriptor: {
                  objectName: "dataCard",
                  propertyName: "fontUnderline",
                },
                value: false,
              },
            },
          },
        },
        {
          displayName: "Font Color",
          uid: "dataCard_dataDesign_fontColor_slice",
          control: {
            type: powerbi.visuals.FormattingComponent.ColorPicker,
            properties: {
              descriptor: {
                objectName: "dataCard",
                propertyName: "fontColor",
              },
              value: { value: "#01B8AA" },
            },
          },
        },
      ],
    };
  }

  const xAxisFormattingGroup = createAxisFormattingGroup("X-Axis---", "x-AxisFormatting_uid");

  dataCard.groups.push(xAxisFormattingGroup);

  const formattingModel: powerbi.visuals.FormattingModel = { cards: [dataCard] };
  return formattingModel;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;objects in capabilities.json file for formatting pane:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; "objects":{

    "dataCard": {

      "properties": {

        "fontSize": {

          "type": {

            "formatting": {

              "fontSize": true

            }

          }

        },

        "fontFamily": {

          "type": {

            "formatting": {

              "fontFamily": true

            }

          }

        },

        "fontBold": {

          "type": {

            "bool": true

          }

        },

        "fontUnderline": {

          "type": {

            "bool": true

          }

        },

        "fontItalic": {

          "type": {

            "bool": true

          }

        },

        "fontColor": {

          "type": {

            "fill": {

              "solid": {

                "color": true

              }

            }

          }

        }

      }

    },

    "xAxisFormatting": {

      "displayName": "X-Axis Formatting",

      "properties": {

        "fontFamily": {

          "displayName": "Font Family",

          "type": { "text": true }

        },

        "fontSize": {

          "displayName": "Font Size",

          "type": { "numeric": true }

        },

        "fontColor": {

          "displayName": "Font Color",

          "type": { "fill": { "solid": { "color": true } } }

        }

      }

    }

  }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;my xAxis label is in visual.ts file is :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;const xAxisLabels = this.xAxisGroup
  .attr('transform', 'translate(0,' + chartHeight + ')')
  .call(axisBottom(xScale).ticks(5))
  .selectAll('text')
setting.ts file:&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;setting.ts:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;export class VisualFormattingSettingsModel extends FormattingSettingsModel {

  xAxisLabelFormatting: {
    fontFamily: any;
    fontSize: any;
    fontColor: any;
  };
}
  
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&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-inline" image-alt="AakashMarasini_0-1694490396098.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/967355i4426B20361B9A3A0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AakashMarasini_0-1694490396098.png" alt="AakashMarasini_0-1694490396098.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Please help me in the implemetation of formatting pane for x axis label.&lt;/P&gt;&lt;P&gt;Thank You!&lt;BR /&gt;#customvisual&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/397"&gt;@dm-p&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/304461"&gt;@WZorn&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2023 03:46:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/getformattingmodel-implementation/m-p/3425439#M7955</guid>
      <dc:creator>AakashMarasini</dc:creator>
      <dc:date>2023-09-12T03:46:47Z</dc:date>
    </item>
    <item>
      <title>Re: getformattingmodel() implementation</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/getformattingmodel-implementation/m-p/3425457#M7956</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/519176"&gt;@AakashMarasini&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've done limited work with the formatting model, but my understanding is that you would need to pass your current visual settings into your &lt;FONT face="courier new,courier"&gt;createAxisFormattingGroup&lt;/FONT&gt; function so that you can sub them in to where you are currently hard-coding them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your settings are available at the class level (and assuming they are scoped as &lt;FONT face="courier new,courier"&gt;this.settings&lt;/FONT&gt;), you could probably get away with the following:&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;  function createAxisFormattingGroup(displayName: string, uid: string): powerbi.visuals.FormattingGroup {
    return {
      displayName: displayName,
      uid: uid,
      slices: [
        {
          uid: "data_font_control_slice_uid",
          displayName: "Font",
          control: {
            type: powerbi.visuals.FormattingComponent.FontControl,
            properties: {
              fontFamily: {
                descriptor: {
                  objectName: "dataCard",
                  propertyName: "fontFamily",
                },
                value: this.settings.dataCard.fontFamily,
              },
              fontSize: {
                descriptor: {
                  objectName: "dataCard",
                  propertyName: "fontSize",
                },
                value: 20,
              },
              bold: {
                descriptor: {
                  objectName: "dataCard",
                  propertyName: "fontBold",
                },
                value: this.settings.dataCard.fontBold,
              },
              italic: {
                descriptor: {
                  objectName: "dataCard",
                  propertyName: "fontItalic",
                },
                value: this.settings.dataCard.fontItalic,
              },
              underline: {
                descriptor: {
                  objectName: "dataCard",
                  propertyName: "fontUnderline",
                },
                value: this.settings.dataCard.fontUnderline,
              },
            },
          },
        },
        {
          displayName: "Font Color",
          uid: "dataCard_dataDesign_fontColor_slice",
          control: {
            type: powerbi.visuals.FormattingComponent.ColorPicker,
            properties: {
              descriptor: {
                objectName: "dataCard",
                propertyName: "fontColor",
              },
              value: { value: this.settings.dataCard.fontColor },
            },
          },
        },
      ],
    };
  }&lt;/LI-CODE&gt;
&lt;P&gt;In terms of making the function more portable, you might want to make the desired settings object a property of the function, so that you can refactor more easily, but the above implementation would probably work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm not sure if it helps, but I have an implementation I'm working on that you might be able to crib from. It's not in my master branch as this release is still undergoing testing, but you should be able to see the source code &lt;A href="https://github.com/deneb-viz/deneb/tree/812494ba39404fa7812bfcc4bf8d84f9d8b6e03d" target="_self"&gt;as of this commit&lt;/A&gt;. Key parts for reference would be:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://github.com/deneb-viz/deneb/blob/812494ba39404fa7812bfcc4bf8d84f9d8b6e03d/src/Deneb.ts#L191-L217" target="_self"&gt;My &lt;FONT face="courier new,courier"&gt;getFormattingModel&lt;/FONT&gt; function&lt;/A&gt; - you'll notice that I have declared a getFormattingCard method in each settings class that I use instead, as this allows me direct access to the settings values in that class.&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://github.com/deneb-viz/deneb/blob/812494ba39404fa7812bfcc4bf8d84f9d8b6e03d/src/properties/theme-settings.ts#L23-L49" target="_self"&gt;An example of a &lt;FONT face="courier new,courier"&gt;getFormattingCard&lt;/FONT&gt; method&lt;/A&gt; - I've chosen a class with a single property, as I have my own methods that I use to generate controls and a settings class with more properties might obfuscate things too much (but hopefully you can see that due to how it's scoped, it's easy to access the settings value from that class where I need it).&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;This is probably the limit of my current knowledge with the formatting cards, but hopefully some of it may help. Good luck!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Daniel&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2023 04:08:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/getformattingmodel-implementation/m-p/3425457#M7956</guid>
      <dc:creator>dm-p</dc:creator>
      <dc:date>2023-09-12T04:08:59Z</dc:date>
    </item>
    <item>
      <title>Re: getformattingmodel() implementation</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/getformattingmodel-implementation/m-p/3427468#M7963</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/397"&gt;@dm-p&lt;/a&gt;&amp;nbsp; for your quick response. While I used this.setting, it didn't work. So I have used&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;getFormattingModel&lt;/SPAN&gt;&lt;SPAN&gt;() for formatting and it and finally worked.&lt;BR /&gt;Thanks Again!&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 13 Sep 2023 02:56:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/getformattingmodel-implementation/m-p/3427468#M7963</guid>
      <dc:creator>AakashMarasini</dc:creator>
      <dc:date>2023-09-13T02:56:50Z</dc:date>
    </item>
  </channel>
</rss>

