<?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 Bar Chart Show Axis in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Bar-Chart-Show-Axis/m-p/507396#M15631</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new, i made a simple bar chart that the user can put a category and a&amp;nbsp;measure. Now I would like to show the Axis information, can anyone help?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is where I got by myself:&lt;/P&gt;&lt;PRE&gt;capabilities.json
{
    "dataRoles": [
        {
            "displayName": "Category Data",
            "name": "category",
            "kind": "Grouping"
        },
        {
            "displayName": "Measure Data",
            "name": "measure",
            "kind": "Measure"
        }
    ],
    "objects": {
        
        "newbar": {
            "displayName": "New Bar",
            "properties": {
                "barColor": {
                    "displayName": "Color",
                    "description": "The fill color of the new bar.",
                    "type": {
                        "fill": {
                            "solid": {
                                "color": true
                            }
                        }
                    }
                }
            }
        }    
    },
    "dataViewMappings": [
        {        
            "conditions": [
                {
                    "category": {
                        "max": 1
                    },
                    "measure": {
                        "max": 1
                    }
                }
            ],
            "categorical": {
                "categories": {
                    "for": {
                        "in": "category"
                    },
                    "dataReductionAlgorithm": {
                        "top": {}
                    }
                },
                "values": {
                    "select": [
                        {
                            "bind": {
                                "to": "measure"
                            }
                        }
                    ]
                }
            }
        }
    ]
}


&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;settings.ts
module powerbi.extensibility.visual {
    "use strict";
    import DataViewObjectsParser = powerbi.extensibility.utils.dataview.DataViewObjectsParser;

    export class barSettings {
      public barColor: string = "black";
     }
     export class VisualSettings extends DataViewObjectsParser {
      public newbar: barSettings = new barSettings();
     }
     &lt;/PRE&gt;&lt;PRE&gt;visual.ts
module powerbi.extensibility.visual {

    interface BarChartViewModel {
        dataPoints: BarChartDataPoint[];
        dataMax: number;
    };

    interface BarChartDataPoint {
        value: number;
        category: string;

    };

    function visualTransform(options: VisualUpdateOptions, host: IVisualHost): BarChartViewModel {
        let dataViews = options.dataViews;
        let viewModel: BarChartViewModel = {
            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 viewModel;
        let categorical = dataViews[0].categorical;
        let category = categorical.categories[0];
        let dataValue = categorical.values[0];
        let barChartDataPoints: BarChartDataPoint[] = [];
        let dataMax: number;

        let colorPalette: IColorPalette = host.colorPalette;

        for (let i = 0, len = Math.max(category.values.length, dataValue.values.length); i &amp;lt; len; i++) {
            barChartDataPoints.push({
                category: &amp;lt;string&amp;gt;category.values[i],
                value: &amp;lt;number&amp;gt;dataValue.values[i]
                
            });
        }
        dataMax = &amp;lt;number&amp;gt;dataValue.maxLocal;
        return {
            dataPoints: barChartDataPoints,
            dataMax: dataMax
        };
    }
    export class Visual implements IVisual {

        private svg: d3.Selection&amp;lt;SVGElement&amp;gt;;
        private host: IVisualHost;
        private barChartContainer: d3.Selection&amp;lt;SVGElement&amp;gt;;
        private barContainer: d3.Selection&amp;lt;SVGElement&amp;gt;;
        private bars: d3.Selection&amp;lt;SVGElement&amp;gt;;
        private visualSettings: VisualSettings;
        static Config = {
            xScalePadding: 0.1,
        };


        constructor(options: VisualConstructorOptions) {
            console.log('Visual constructor', options);

            this.host = options.host;
            let svg = this.svg = d3.select(options.element)
                .append('svg')
                .classed('barChart', true);
            this.barContainer = svg.append('g')
                .classed('barContainer', true);
        }
   

        public enumerateObjectInstances(options: EnumerateVisualObjectInstancesOptions): VisualObjectInstanceEnumeration {
            const settings: VisualSettings = this.visualSettings || 
           VisualSettings.getDefault() as VisualSettings;
            return VisualSettings.enumerateObjectInstances(settings, options);
           }
           
           
        public update(options: VisualUpdateOptions) {

            let viewModel: BarChartViewModel = visualTransform(options, this.host);
            let dataView: DataView = options.dataViews[0]
            this.visualSettings = VisualSettings.parse&amp;lt;VisualSettings&amp;gt;(dataView);

            let width = options.viewport.width;
            let height = options.viewport.height;
            this.svg.attr({
                width: width,
                height: height
            });
            let yScale = d3.scale.linear()
                .domain([0, viewModel.dataMax])
                .range([height, 0]);
            let xScale = d3.scale.ordinal()
                .domain(viewModel.dataPoints.map(d =&amp;gt; d.category))
                .rangeRoundBands([0, width], Visual.Config.xScalePadding);
            let bars = this.barContainer.selectAll('.bar').data(viewModel.dataPoints);
            bars.enter()
                .append('rect')
                .classed('bar', true);
            bars.attr({
                width: xScale.rangeBand(),
                height: d =&amp;gt; height - yScale(d.value),
                y: d =&amp;gt; yScale(d.value),
                x: d =&amp;gt; xScale(d.category),
                fill: d =&amp;gt; this.visualSettings.newbar.barColor
                //d.color
            });
            bars.exit()
                .remove();
        }

        public destroy(): void {
            //TODO: Perform any cleanup tasks here
            //Perform any cleanup tasks here
        }
    }
} &lt;/PRE&gt;</description>
    <pubDate>Tue, 04 Sep 2018 20:18:17 GMT</pubDate>
    <dc:creator>miguelsalles</dc:creator>
    <dc:date>2018-09-04T20:18:17Z</dc:date>
    <item>
      <title>Bar Chart Show Axis</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Bar-Chart-Show-Axis/m-p/507396#M15631</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new, i made a simple bar chart that the user can put a category and a&amp;nbsp;measure. Now I would like to show the Axis information, can anyone help?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is where I got by myself:&lt;/P&gt;&lt;PRE&gt;capabilities.json
{
    "dataRoles": [
        {
            "displayName": "Category Data",
            "name": "category",
            "kind": "Grouping"
        },
        {
            "displayName": "Measure Data",
            "name": "measure",
            "kind": "Measure"
        }
    ],
    "objects": {
        
        "newbar": {
            "displayName": "New Bar",
            "properties": {
                "barColor": {
                    "displayName": "Color",
                    "description": "The fill color of the new bar.",
                    "type": {
                        "fill": {
                            "solid": {
                                "color": true
                            }
                        }
                    }
                }
            }
        }    
    },
    "dataViewMappings": [
        {        
            "conditions": [
                {
                    "category": {
                        "max": 1
                    },
                    "measure": {
                        "max": 1
                    }
                }
            ],
            "categorical": {
                "categories": {
                    "for": {
                        "in": "category"
                    },
                    "dataReductionAlgorithm": {
                        "top": {}
                    }
                },
                "values": {
                    "select": [
                        {
                            "bind": {
                                "to": "measure"
                            }
                        }
                    ]
                }
            }
        }
    ]
}


&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;settings.ts
module powerbi.extensibility.visual {
    "use strict";
    import DataViewObjectsParser = powerbi.extensibility.utils.dataview.DataViewObjectsParser;

    export class barSettings {
      public barColor: string = "black";
     }
     export class VisualSettings extends DataViewObjectsParser {
      public newbar: barSettings = new barSettings();
     }
     &lt;/PRE&gt;&lt;PRE&gt;visual.ts
module powerbi.extensibility.visual {

    interface BarChartViewModel {
        dataPoints: BarChartDataPoint[];
        dataMax: number;
    };

    interface BarChartDataPoint {
        value: number;
        category: string;

    };

    function visualTransform(options: VisualUpdateOptions, host: IVisualHost): BarChartViewModel {
        let dataViews = options.dataViews;
        let viewModel: BarChartViewModel = {
            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 viewModel;
        let categorical = dataViews[0].categorical;
        let category = categorical.categories[0];
        let dataValue = categorical.values[0];
        let barChartDataPoints: BarChartDataPoint[] = [];
        let dataMax: number;

        let colorPalette: IColorPalette = host.colorPalette;

        for (let i = 0, len = Math.max(category.values.length, dataValue.values.length); i &amp;lt; len; i++) {
            barChartDataPoints.push({
                category: &amp;lt;string&amp;gt;category.values[i],
                value: &amp;lt;number&amp;gt;dataValue.values[i]
                
            });
        }
        dataMax = &amp;lt;number&amp;gt;dataValue.maxLocal;
        return {
            dataPoints: barChartDataPoints,
            dataMax: dataMax
        };
    }
    export class Visual implements IVisual {

        private svg: d3.Selection&amp;lt;SVGElement&amp;gt;;
        private host: IVisualHost;
        private barChartContainer: d3.Selection&amp;lt;SVGElement&amp;gt;;
        private barContainer: d3.Selection&amp;lt;SVGElement&amp;gt;;
        private bars: d3.Selection&amp;lt;SVGElement&amp;gt;;
        private visualSettings: VisualSettings;
        static Config = {
            xScalePadding: 0.1,
        };


        constructor(options: VisualConstructorOptions) {
            console.log('Visual constructor', options);

            this.host = options.host;
            let svg = this.svg = d3.select(options.element)
                .append('svg')
                .classed('barChart', true);
            this.barContainer = svg.append('g')
                .classed('barContainer', true);
        }
   

        public enumerateObjectInstances(options: EnumerateVisualObjectInstancesOptions): VisualObjectInstanceEnumeration {
            const settings: VisualSettings = this.visualSettings || 
           VisualSettings.getDefault() as VisualSettings;
            return VisualSettings.enumerateObjectInstances(settings, options);
           }
           
           
        public update(options: VisualUpdateOptions) {

            let viewModel: BarChartViewModel = visualTransform(options, this.host);
            let dataView: DataView = options.dataViews[0]
            this.visualSettings = VisualSettings.parse&amp;lt;VisualSettings&amp;gt;(dataView);

            let width = options.viewport.width;
            let height = options.viewport.height;
            this.svg.attr({
                width: width,
                height: height
            });
            let yScale = d3.scale.linear()
                .domain([0, viewModel.dataMax])
                .range([height, 0]);
            let xScale = d3.scale.ordinal()
                .domain(viewModel.dataPoints.map(d =&amp;gt; d.category))
                .rangeRoundBands([0, width], Visual.Config.xScalePadding);
            let bars = this.barContainer.selectAll('.bar').data(viewModel.dataPoints);
            bars.enter()
                .append('rect')
                .classed('bar', true);
            bars.attr({
                width: xScale.rangeBand(),
                height: d =&amp;gt; height - yScale(d.value),
                y: d =&amp;gt; yScale(d.value),
                x: d =&amp;gt; xScale(d.category),
                fill: d =&amp;gt; this.visualSettings.newbar.barColor
                //d.color
            });
            bars.exit()
                .remove();
        }

        public destroy(): void {
            //TODO: Perform any cleanup tasks here
            //Perform any cleanup tasks here
        }
    }
} &lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Sep 2018 20:18:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Bar-Chart-Show-Axis/m-p/507396#M15631</guid>
      <dc:creator>miguelsalles</dc:creator>
      <dc:date>2018-09-04T20:18:17Z</dc:date>
    </item>
    <item>
      <title>Re: Bar Chart Show Axis</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Bar-Chart-Show-Axis/m-p/507994#M15649</link>
      <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/79728"&gt;@miguelsalles&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See&amp;nbsp;&lt;A href="https://github.com/Microsoft/PowerBI-visuals-sampleBarChart" target="_blank"&gt;Sample Bar Chart Repo&lt;/A&gt;&amp;nbsp;as an example.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Sep 2018 09:20:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Bar-Chart-Show-Axis/m-p/507994#M15649</guid>
      <dc:creator>v-chuncz-msft</dc:creator>
      <dc:date>2018-09-05T09:20:59Z</dc:date>
    </item>
    <item>
      <title>Re: Bar Chart Show Axis</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Bar-Chart-Show-Axis/m-p/508133#M15656</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems that this tutorial is deprecated and it is not needed to use the object enumeration anymore, I am trying to adequate the tutorial without it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Will post solution here whenever I get it right.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Sep 2018 11:43:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Bar-Chart-Show-Axis/m-p/508133#M15656</guid>
      <dc:creator>miguelsalles</dc:creator>
      <dc:date>2018-09-05T11:43:09Z</dc:date>
    </item>
  </channel>
</rss>

