<?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: custom visual format in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/custom-visual-format/m-p/4340280#M58779</link>
    <description>&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;&lt;SPAN&gt;Hi,&amp;nbsp;@Anonymous&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;Thanks for reaching out to the Microsoft fabric community forum.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;" lang="zh-CN"&gt;1.In Power BI custom visuals, you can make colours selectable by using the colorPalette service.&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vlinyulumsft_0-1734933553245.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1218722i61E4E86E427B2E46/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vlinyulumsft_0-1734933553245.png" alt="vlinyulumsft_0-1734933553245.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;" lang="zh-CN"&gt;2.You can combine it with ColorHelper. Below is a screenshot of the relevant documentation for ColorHelper:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vlinyulumsft_1-1734933553246.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1218723iACC253C714673804/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vlinyulumsft_1-1734933553246.png" alt="vlinyulumsft_1-1734933553246.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;" lang="zh-CN"&gt;Here is a simple example:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;this.colorHelper = new ColorHelper(this.visualHost.colorPalette);&lt;/LI-CODE&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;" lang="zh-CN"&gt;The ColorHelper class is typically used to simplify colour management, especially when you need to dynamically set colours based on data. It can fetch colours from the colorPalette and adjust them as needed.&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;" lang="zh-CN"&gt;For more details, please refer to:&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&lt;A href="https://learn.microsoft.com/en-us/power-bi/developer/visuals/add-colors-power-bi-visual" target="_blank"&gt;&lt;SPAN&gt;Add colors to your Power BI custom visuals - Power BI | Microsoft Learn&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;" lang="zh-CN"&gt;3.Below is the relevant documentation for your issue, which I hope will be helpful:&lt;/P&gt;
&lt;P style="margin: 0in;"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://learn.microsoft.com/en-us/power-bi/developer/visuals/on-object-formatting-api" target="_blank"&gt;&lt;SPAN&gt;Format objects directly API in Power BI Visuals - Power BI | Microsoft Learn&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;A href="https://learn.microsoft.com/en-us/power-bi/developer/visuals/custom-visual-develop-tutorial-format-options" target="_blank"&gt;&lt;SPAN&gt;Add formatting options to a Power BI custom visual - Power BI | Microsoft Learn&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;A href="https://learn.microsoft.com/zh-cn/power-bi/developer/visuals/format-pane-example" target="_blank"&gt;&lt;SPAN&gt;Customize the format pane in Power BI custom visuals - Power BI | Microsoft Learn&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;" lang="zh-CN"&gt;4.Of course, Microsoft also provides a lot of sample files, please refer to the following for details:&lt;/P&gt;
&lt;P style="margin: 0in;"&gt;&lt;A href="https://learn.microsoft.com/en-us/power-bi/developer/visuals/samples" target="_blank"&gt;&lt;SPAN&gt;Examples of Power BI visuals - Power BI | Microsoft Learn&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;I&lt;/SPAN&gt;&lt;SPAN&gt;f you have any new discoveries or questions, please feel free to get in touch with us.&lt;BR /&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;Best Regards,&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;Leroy Lu&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;If this post &lt;EM&gt;&lt;STRONG&gt;helps,&lt;/STRONG&gt;&lt;/EM&gt; then please consider Accept it&lt;EM&gt;&lt;STRONG&gt; as the solution &lt;/STRONG&gt;&lt;/EM&gt;to help the other members find it more quickly.&lt;/P&gt;</description>
    <pubDate>Mon, 23 Dec 2024 06:02:14 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-12-23T06:02:14Z</dc:date>
    <item>
      <title>custom visual format</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/custom-visual-format/m-p/4339608#M58771</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Issue:&lt;/STRONG&gt; Trying to create a custom gauge visual but unable to add custom settings.&lt;BR /&gt;Tried adding the "FillColor" parameter, but only the default settings are displayed.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;capabilities.json&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
    "dataRoles": [
        {
            "name": "measure",
            "kind": "Measure",
            "displayName": "Current Value"
        },
        {
            "name": "maxMeasure",
            "kind": "Measure",
            "displayName": "Maximum Value"
        },
        {
            "name": "minMeasure",
            "kind": "Measure",
            "displayName": "Minimum Value"
        }
    ],
    "dataViewMappings": [
        {
            "categorical": {
                "values": {
                    "select": [
                        {
                            "bind": {
                                "to": "measure"
                            }
                        },
                        {
                            "bind": {
                                "to": "maxMeasure"
                            }
                        },
                        {
                            "bind": {
                                "to": "minMeasure"
                            }
                        }
                    ]
                }
            }
        }
    ],
    "objects": {
        "gauge": {
            "displayName": "Gauge Settings",
            "properties": {
                "backgroundColor": {
                    "displayName": "Background Color",
                    "type": {
                        "fill": {
                            "solid": {
                                "color": true
                            }
                        }
                    }
                },
                "textColor": {
                    "displayName": "Text Color",
                    "type": {
                        "fill": {
                            "solid": {
                                "color": true
                            }
                        }
                    }
                },
                "fontSize": {
                    "displayName": "Font Size",
                    "type": {
                        "numeric": true
                    }
                },
                "maxValue": {
                    "displayName": "Maximum Value",
                    "type": {
                        "numeric": true
                    }
                },
                "minValue": {
                    "displayName": "Minimum Value",
                    "type": {
                        "numeric": true
                    }
                },
                "fillColor": {
                    "displayName": "Fill Color",
                    "type": {
                        "fill": {
                            "solid": {
                                "color": true
                            }
                        }
                    }
                }
            }
        }
    },
    "privileges": []
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;STRONG&gt;settings.ts&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;"use strict";

import { dataViewObjectsParser } from "powerbi-visuals-utils-dataviewutils";



export class VisualSettings extends dataViewObjectsParser.DataViewObjectsParser {
    public gauge: GaugeSettings = new GaugeSettings();

    public static parse&amp;lt;T&amp;gt;(dataView: powerbi.DataView): T {
        const settings = new VisualSettings();
        const objects = dataView.metadata.objects;

        if (objects) {
            settings.gauge.backgroundColor = this.getString(objects, "gauge", "backgroundColor", settings.gauge.backgroundColor);
            settings.gauge.textColor = this.getString(objects, "gauge", "textColor", settings.gauge.textColor);
            settings.gauge.fontSize = this.getNumber(objects, "gauge", "fontSize", settings.gauge.fontSize);
            settings.gauge.maxValue = this.getNumber(objects, "gauge", "maxValue", settings.gauge.maxValue);
            settings.gauge.minValue = this.getNumber(objects, "gauge", "minValue", settings.gauge.minValue);
            settings.gauge.fillColor = this.getString(objects, "gauge", "fillColor", settings.gauge.fillColor);
        }

        return settings as T;
    }

    private static getString(objects: any, objectName: string, propertyName: string, defaultValue: string): string {
        const value = objects[objectName]?.[propertyName];
        return typeof value === 'string' ? value : defaultValue;
    }

    private static getNumber(objects: any, objectName: string, propertyName: string, defaultValue: number): number {
        const value = objects[objectName]?.[propertyName];
        if (typeof value === 'number') {
            return value;
        }
        if (typeof value === 'string') {
            const parsedValue = parseFloat(value);
            return isNaN(parsedValue) ? defaultValue : parsedValue;
        }
        return defaultValue;
    }
}
export class GaugeSettings {
    public backgroundColor: string = "#e6e6e6"; // Background color
    public textColor: string = "#000000"; // Text color
    public fontSize: number = 24; // Font size
    public maxValue: number = 100; // Maximum value
    public minValue: number = 0; // Minimum value
    public fillColor: string = "#00FF00"; // Fill color
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Dec 2024 23:57:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/custom-visual-format/m-p/4339608#M58771</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-12-21T23:57:45Z</dc:date>
    </item>
    <item>
      <title>Re: custom visual format</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/custom-visual-format/m-p/4340280#M58779</link>
      <description>&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;&lt;SPAN&gt;Hi,&amp;nbsp;@Anonymous&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;Thanks for reaching out to the Microsoft fabric community forum.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;" lang="zh-CN"&gt;1.In Power BI custom visuals, you can make colours selectable by using the colorPalette service.&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vlinyulumsft_0-1734933553245.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1218722i61E4E86E427B2E46/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vlinyulumsft_0-1734933553245.png" alt="vlinyulumsft_0-1734933553245.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;" lang="zh-CN"&gt;2.You can combine it with ColorHelper. Below is a screenshot of the relevant documentation for ColorHelper:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vlinyulumsft_1-1734933553246.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1218723iACC253C714673804/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vlinyulumsft_1-1734933553246.png" alt="vlinyulumsft_1-1734933553246.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;" lang="zh-CN"&gt;Here is a simple example:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;this.colorHelper = new ColorHelper(this.visualHost.colorPalette);&lt;/LI-CODE&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;" lang="zh-CN"&gt;The ColorHelper class is typically used to simplify colour management, especially when you need to dynamically set colours based on data. It can fetch colours from the colorPalette and adjust them as needed.&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;" lang="zh-CN"&gt;For more details, please refer to:&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&lt;A href="https://learn.microsoft.com/en-us/power-bi/developer/visuals/add-colors-power-bi-visual" target="_blank"&gt;&lt;SPAN&gt;Add colors to your Power BI custom visuals - Power BI | Microsoft Learn&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;" lang="zh-CN"&gt;3.Below is the relevant documentation for your issue, which I hope will be helpful:&lt;/P&gt;
&lt;P style="margin: 0in;"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://learn.microsoft.com/en-us/power-bi/developer/visuals/on-object-formatting-api" target="_blank"&gt;&lt;SPAN&gt;Format objects directly API in Power BI Visuals - Power BI | Microsoft Learn&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;A href="https://learn.microsoft.com/en-us/power-bi/developer/visuals/custom-visual-develop-tutorial-format-options" target="_blank"&gt;&lt;SPAN&gt;Add formatting options to a Power BI custom visual - Power BI | Microsoft Learn&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;A href="https://learn.microsoft.com/zh-cn/power-bi/developer/visuals/format-pane-example" target="_blank"&gt;&lt;SPAN&gt;Customize the format pane in Power BI custom visuals - Power BI | Microsoft Learn&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;" lang="zh-CN"&gt;4.Of course, Microsoft also provides a lot of sample files, please refer to the following for details:&lt;/P&gt;
&lt;P style="margin: 0in;"&gt;&lt;A href="https://learn.microsoft.com/en-us/power-bi/developer/visuals/samples" target="_blank"&gt;&lt;SPAN&gt;Examples of Power BI visuals - Power BI | Microsoft Learn&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;I&lt;/SPAN&gt;&lt;SPAN&gt;f you have any new discoveries or questions, please feel free to get in touch with us.&lt;BR /&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;Best Regards,&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;Leroy Lu&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;If this post &lt;EM&gt;&lt;STRONG&gt;helps,&lt;/STRONG&gt;&lt;/EM&gt; then please consider Accept it&lt;EM&gt;&lt;STRONG&gt; as the solution &lt;/STRONG&gt;&lt;/EM&gt;to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Dec 2024 06:02:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/custom-visual-format/m-p/4340280#M58779</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-12-23T06:02:14Z</dc:date>
    </item>
  </channel>
</rss>

