<?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: What fires the update () method? in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/What-fires-the-update-method/m-p/1696898#M28146</link>
    <description>&lt;P&gt;Hi again,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have checked some more, update() is actually firing but something happens inside the getViewModel when I add the second field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;</description>
    <pubDate>Mon, 01 Mar 2021 21:15:10 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2021-03-01T21:15:10Z</dc:date>
    <item>
      <title>What fires the update () method?</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/What-fires-the-update-method/m-p/1696858#M28145</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am developing a pretty simple custom visual but I cannot fully understand what fires the update() method.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have three data roles and for some strange reason, the update() method is not fired for every field I add to the field pane. It does not seem to be which field I add that causes this issue, it is the order in which I add them. I add a field to the one of the data roles and update() fires. When I add the second field nothing happens. When I then add the third and final field, update() fires again. Could someone help me, I have added the code elements that I think could be relvant below.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As said, it does not seem to matter which field I populate first, it is always the second field that results in "nothing".&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a feeling that it is my getViewModel that is the issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;capabilities.json&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;/P&gt;&lt;LI-CODE lang="javascript"&gt;    "dataRoles": [
        {
            "displayName": "KPI Name",
            "name": "category",
            "kind": "Grouping"
        },
        {
            "displayName": "KPI Value",
            "name": "kpimeasure",
            "kind": "Measure"
        },
        {
            "displayName": "Target Value",
            "name": "targetmeasure",
            "kind": "Measure"
        }
    ],



    "dataViewMappings": [ {
            "conditions": [
                {
                    "category": { "max": 1},
                    "kpimeasure": { "max": 1},
                    "targetmeasure": { "max": 1}
                }
            ],
            "categorical": {
                "categories": { 
                    "for": { "in": "category" },
                    "dataReductionAlgorithm": { "top": {} } 
                },
                "values": {
                    "select": [
                        { "bind": { "to": "kpimeasure" } },
                        { "bind": { "to": "targetmeasure" } }
                    ]
                }
            }
        }
    ]&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;/P&gt;&lt;P&gt;visual.ts&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;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;public update(options: VisualUpdateOptions) {
        
        this.settings = VisualSettings.parse&amp;lt;VisualSettings&amp;gt;(options.dataViews[0]); 

        let viewModel = this.getViewModel(options);

        let width = options.viewport.width;
        let height = options.viewport.height;

        this.svg.attr("width", width);
        this.svg.attr("height", height);

        let labelbackground = this.labelBackground
            .attr("width", width)
            .attr("height", height * this.labelSectionPercentage)
            .attr("fill", viewModel.labelBackgroundColor);
        debugger;
        let labeltext = this.labelGroup
            .selectAll(".labelText")
            .data(viewModel.dataPoints, d =&amp;gt; (d as DataPoint).label)
            .attr("x", width / 2)
            .attr("y", height * this.labelSectionPercentage / 2)
            .attr("alignment-baseline", "middle")
            .attr("text-anchor", "middle")
            .attr("fill", "white")
            .enter()
            .append("text")
            .classed("labelText", true)
            .text(d =&amp;gt; d.label);
    



        this.labelGroup
            .selectAll(".labelText")
            .data(viewModel.dataPoints, d =&amp;gt; (d as DataPoint).label)
            .exit()
            .remove();


    }

private getViewModel(options: VisualUpdateOptions): ViewModel {

        let dv = options.dataViews;

        let viewModel: ViewModel = {
            dataPoints: [],
            labelBackgroundColor: "none"
        };

        if (!dv
            || !dv[0]
            || !dv[0].categorical
            || !dv[0].categorical.categories
            || !dv[0].categorical.categories[0].source
            || !dv[0].categorical.values
            || !dv[0].metadata)
            
            {
                console.log(dv);
                return viewModel;
            }

        let view = dv[0].categorical;
        let categories = view.categories[0];
        let values = view.values[0];
        let targets = view.values[1];

        for (let i = 0, len = Math.max(categories.values.length, values.values.length, targets.values.length); i &amp;lt; len; i++) {
            viewModel.dataPoints.push({
                label: &amp;lt;string&amp;gt;categories.values[i],
                value: &amp;lt;number&amp;gt;values.values[i],
                target: &amp;lt;string&amp;gt;targets.values[i]
                
            });
        };
        
        viewModel.labelBackgroundColor = "blue"

        return viewModel;
    }&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;/P&gt;</description>
      <pubDate>Mon, 01 Mar 2021 21:13:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/What-fires-the-update-method/m-p/1696858#M28145</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-03-01T21:13:25Z</dc:date>
    </item>
    <item>
      <title>Re: What fires the update () method?</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/What-fires-the-update-method/m-p/1696898#M28146</link>
      <description>&lt;P&gt;Hi again,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have checked some more, update() is actually firing but something happens inside the getViewModel when I add the second field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;</description>
      <pubDate>Mon, 01 Mar 2021 21:15:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/What-fires-the-update-method/m-p/1696898#M28146</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-03-01T21:15:10Z</dc:date>
    </item>
    <item>
      <title>Re: What fires the update () method?</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/What-fires-the-update-method/m-p/1702090#M28188</link>
      <description>&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;HI&amp;nbsp;@Anonymous&lt;/a&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;According to your decision, It sounds like you want to further debug with your custom visual update events.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;If that is the case, you can take a look at the following links about update event, debug with custom visual and local storage API(may be used to export the logs) of these helps:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;&lt;A href="https://docs.microsoft.com/en-us/power-bi/developer/visuals/visual-api#update" target="_self"&gt;Visual API#update&lt;/A&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;&lt;A href="https://docs.microsoft.com/en-us/power-bi/developer/visuals/local-storage" target="_self"&gt;Local Storage API&lt;/A&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;&lt;A href="https://docs.microsoft.com/en-us/power-bi/developer/visuals/visuals-how-to-debug#how-to-debug-power-bi-visuals" target="_self"&gt;How to debug Power BI visuals&lt;/A&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Regards,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Xiaoxin Sheng&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 02:02:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/What-fires-the-update-method/m-p/1702090#M28188</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-03-04T02:02:16Z</dc:date>
    </item>
    <item>
      <title>Re: What fires the update () method?</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/What-fires-the-update-method/m-p/1702231#M28192</link>
      <description>&lt;P&gt;Hi @Anonymous&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;In terms of what causes the developer visual host to call the update method, &lt;A href="https://docs.microsoft.com/en-us/power-bi/developer/visuals/power-bi-visuals-concept?WT.mc_id=DP-MVP-5003712" target="_self"&gt;this is pretty good overview&lt;/A&gt; and should help you to understand what events you're calling in your code may set it going outside of anything Power BI might be doing.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Daniel&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 03:29:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/What-fires-the-update-method/m-p/1702231#M28192</guid>
      <dc:creator>dm-p</dc:creator>
      <dc:date>2021-03-04T03:29:55Z</dc:date>
    </item>
  </channel>
</rss>

