<?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: How to add Data Label to a BarChart? in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Custom-Visual-How-to-add-Data-Label-to-a-BarChart/m-p/522012#M16098</link>
    <description>&lt;P&gt;Please use tooltipService to render tooltips. You can follow our &lt;A href="https://github.com/Microsoft/PowerBI-visuals/blob/master/Visual/Tooltips.md" target="_self"&gt;documentation&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt; color: #333333;"&gt;Ignat Vilesov,&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt; color: #333333;"&gt;Software Engineer&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt; color: #333333;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt; color: #333333;"&gt;Microsoft Power BI Custom Visuals&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&lt;A href="mailto:pbicvsupport@microsoft.com" target="_blank"&gt;pbicvsupport@microsoft.com&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 21 Sep 2018 07:16:14 GMT</pubDate>
    <dc:creator>v-viig</dc:creator>
    <dc:date>2018-09-21T07:16:14Z</dc:date>
    <item>
      <title>Custom Visual: How to add Data Label to a BarChart?</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-Visual-How-to-add-Data-Label-to-a-BarChart/m-p/521806#M16095</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am currently building a&amp;nbsp;Custom Visuals inspired from the Bar Chart sample and I am trying to figure out a way to display the Data labels on top of each bar (Outside End).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate any help/reference on this topic.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;module powerbi.extensibility.visual {
    function visualTransform(options: VisualUpdateOptions, host: IVisualHost) {
        let dataViews = options.dataViews;

        let dataInfo = {
            dataPoints: [],
            dataMax: 0
        };

        if (!dataViews
            || !dataViews[0]
            || !dataViews[0].categorical
            || !dataViews[0].categorical.categories
            || !dataViews[0].categorical.categories[0].source
            || !dataViews[0].categorical.values)
            return dataInfo;

        let categorical = dataViews[0].categorical;
        let category = categorical.categories[0];
        let dataValue = categorical.values[0];

        let dataPoints = [];
        let dataMax: number;

        for (let i = 0, len = Math.max(category.values.length, dataValue.values.length); i &amp;lt; len; i++) {
            dataPoints.push({
                category: &amp;lt;string&amp;gt;category.values[i],
                value: dataValue.values[i]
            });
        }
        dataMax = &amp;lt;number&amp;gt;dataValue.maxLocal;

        return {
            dataPoints: dataPoints,
            dataMax: dataMax
        };
    }

    export class Visual implements IVisual {
        private host: IVisualHost;
        private svg: d3.Selection&amp;lt;SVGElement&amp;gt;;
        private barContainer: d3.Selection&amp;lt;SVGElement&amp;gt;;

        constructor(options: VisualConstructorOptions) {
            this.host = options.host;
            this.svg = d3.select(options.element)
                .append('svg')
                .classed('barChart', true);

            this.barContainer = this.svg
                .append('g')
                .classed('barContainer', true);
        }

        public update(options: VisualUpdateOptions) {
            let transformedData = visualTransform(options, this.host);
            let width = options.viewport.width;
            let height = options.viewport.height;

            this.svg.attr({
                width: width,
                height: height
            });

            let yScale = d3.scale.linear()
                .domain([0, transformedData.dataMax])
                .range([height, 0]);

            let xScale = d3.scale.ordinal()
                .domain(transformedData.dataPoints.map(dataPoint =&amp;gt; dataPoint.category))
                .rangeRoundBands([0, width], 0.1, 0.2);

            let bars = this.barContainer
                .selectAll('.bar')
                .data(transformedData.dataPoints);

            bars.enter()
                .append('rect')
                .classed('bar', true);

            bars.attr({
                width: xScale.rangeBand(),
                height: data =&amp;gt; height - yScale(&amp;lt;number&amp;gt;data.value),
                x: data =&amp;gt; xScale(data.category),
                y: data =&amp;gt; yScale(&amp;lt;number&amp;gt;data.value)
            });

            bars.exit().remove();
        }
    }
}&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Sep 2018 04:16:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-Visual-How-to-add-Data-Label-to-a-BarChart/m-p/521806#M16095</guid>
      <dc:creator>Maikeru</dc:creator>
      <dc:date>2018-09-21T04:16:09Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Visual: How to add Data Label to a BarChart?</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-Visual-How-to-add-Data-Label-to-a-BarChart/m-p/522012#M16098</link>
      <description>&lt;P&gt;Please use tooltipService to render tooltips. You can follow our &lt;A href="https://github.com/Microsoft/PowerBI-visuals/blob/master/Visual/Tooltips.md" target="_self"&gt;documentation&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt; color: #333333;"&gt;Ignat Vilesov,&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt; color: #333333;"&gt;Software Engineer&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt; color: #333333;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt; color: #333333;"&gt;Microsoft Power BI Custom Visuals&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&lt;A href="mailto:pbicvsupport@microsoft.com" target="_blank"&gt;pbicvsupport@microsoft.com&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 07:16:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-Visual-How-to-add-Data-Label-to-a-BarChart/m-p/522012#M16098</guid>
      <dc:creator>v-viig</dc:creator>
      <dc:date>2018-09-21T07:16:14Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Visual: How to add Data Label to a BarChart?</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-Visual-How-to-add-Data-Label-to-a-BarChart/m-p/522210#M16107</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/17823"&gt;@v-viig&lt;/a&gt;!&lt;BR /&gt;I followed the online documentation and was able to add Tooltips to my visual.&lt;/P&gt;&lt;P&gt;However the requirement is to display the data Labels without having to hover each bar.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 09:21:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-Visual-How-to-add-Data-Label-to-a-BarChart/m-p/522210#M16107</guid>
      <dc:creator>Maikeru</dc:creator>
      <dc:date>2018-09-21T09:21:26Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Visual: How to add Data Label to a BarChart?</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-Visual-How-to-add-Data-Label-to-a-BarChart/m-p/523647#M16134</link>
      <description>&lt;P&gt;TooltipService is to show tooltip on hover event. To show labels all the time we would recommend to develop own Label component.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt; color: #333333;"&gt;Ignat Vilesov,&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt; color: #333333;"&gt;Software Engineer&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt; color: #333333;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt; color: #333333;"&gt;Microsoft Power BI Custom Visuals&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&lt;A href="mailto:pbicvsupport@microsoft.com" target="_blank"&gt;pbicvsupport@microsoft.com&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Sep 2018 07:26:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-Visual-How-to-add-Data-Label-to-a-BarChart/m-p/523647#M16134</guid>
      <dc:creator>v-viig</dc:creator>
      <dc:date>2018-09-24T07:26:14Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Visual: How to add Data Label to a BarChart?</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-Visual-How-to-add-Data-Label-to-a-BarChart/m-p/524631#M16157</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/17823"&gt;@v-viig&lt;/a&gt;, I will look further into this. Appreciate your time.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Sep 2018 04:34:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-Visual-How-to-add-Data-Label-to-a-BarChart/m-p/524631#M16157</guid>
      <dc:creator>Maikeru</dc:creator>
      <dc:date>2018-09-25T04:34:30Z</dc:date>
    </item>
  </channel>
</rss>

