<?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: Sliding legend in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/771487#M20466</link>
    <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/397"&gt;@dm-p&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't use DAX since I'm using live connection to OLAP cube. I wanted to recreate line chart, but make cumulative calculations inside of visual. However, by legend doesn't work, as I mentioned before.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Yerkhan&lt;/P&gt;</description>
    <pubDate>Wed, 21 Aug 2019 06:07:39 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-08-21T06:07:39Z</dc:date>
    <item>
      <title>Sliding legend</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/744104#M20038</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I saw sliding legend in one of the visuals, which are built in Power BI desktop.&lt;/P&gt;&lt;P&gt;How this feature can be recreated in custom visual?&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Yerkhan&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2019 05:53:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/744104#M20038</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-19T05:53:50Z</dc:date>
    </item>
    <item>
      <title>Re: Sliding legend</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/745279#M20055</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Do you have an example of where you saw it, or what you are trying to achieve? Is it a particular custom visual? If so, which one? If we can get an idea of what you're aiming for then it might be possible to provide more targeted help.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 02:09:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/745279#M20055</guid>
      <dc:creator>dm-p</dc:creator>
      <dc:date>2019-07-22T02:09:56Z</dc:date>
    </item>
    <item>
      <title>Re: Sliding legend</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/745312#M20056</link>
      <description>&lt;P&gt;Hi&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;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I meant this type of legend, as in this visual:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 339px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/179246i5F4CABF0B1EAF03F/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Legend in this visual slides to right, in case of large legend.&lt;/P&gt;&lt;P&gt;I wanted to use this type of legend in my custom visual.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Yerkhan&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 02:54:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/745312#M20056</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-22T02:54:24Z</dc:date>
    </item>
    <item>
      <title>Re: Sliding legend</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/745365#M20057</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&lt;/a&gt;,&amp;nbsp;and thanks for clarifying &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Assuming you're using &lt;FONT face="courier new,courier"&gt;&lt;A href="https://github.com/microsoft/powerbi-visuals-utils-chartutils/blob/master/docs/api/legend.md#createLegend" target="_self"&gt;createLegend&lt;/A&gt;&lt;/FONT&gt;&amp;nbsp;in &lt;FONT face="courier new,courier"&gt;&lt;A href="https://microsoft.github.io/PowerBI-visuals/docs/libraries-and-utilities/chartutils/" target="_self"&gt;powerbi-visuals-utils-chartutils&lt;/A&gt;&lt;/FONT&gt; to manage the creation of your legend, you need to set the &lt;FONT face="courier new,courier"&gt;isScrollable&lt;/FONT&gt; property to &lt;FONT face="courier new,courier"&gt;true&lt;/FONT&gt;.&lt;/P&gt;&lt;P&gt;If your legend exceeds the area the function reserves for it in the visual viewport, then you'll get the button to scroll to see the additional items.&lt;/P&gt;&lt;P&gt;Good luck!&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 04:19:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/745365#M20057</guid>
      <dc:creator>dm-p</dc:creator>
      <dc:date>2019-07-22T04:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: Sliding legend</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/745366#M20058</link>
      <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/397"&gt;@dm-p&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks! Will try this approach.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Yerkhan&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 04:21:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/745366#M20058</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-22T04:21:46Z</dc:date>
    </item>
    <item>
      <title>Re: Sliding legend</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/745387#M20059</link>
      <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/397"&gt;@dm-p&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please provide code of visual, where this legend is implemented?&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have some difficulties with adding it by github guide.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Yerkhan&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 05:21:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/745387#M20059</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-22T05:21:00Z</dc:date>
    </item>
    <item>
      <title>Re: Sliding legend</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/746104#M20073</link>
      <description>&lt;P&gt;I had a look at this, and the documentation of this library is quite out of date, and there's a number of quirks to getting it to work properly, which didn't help.&lt;/P&gt;&lt;P&gt;It took me about 3 hours to re-learn for the new v3 SDK and work out how to avoid breaking it, so I can understand why you're having trouble. I haven't looked at it in quite some time and it definitely used to work better. It's going to be fun to migrate some of my stuff to this version... &lt;img id="smileyfrustrated" class="emoticon emoticon-smileyfrustrated" src="https://community.fabric.microsoft.com/i/smilies/16x16_smiley-frustrated.png" alt="Smiley Frustrated" title="Smiley Frustrated" /&gt;&amp;nbsp; &amp;nbsp;I hear the team are working on improving the documentation... I really hope so.&lt;/P&gt;&lt;P&gt;To get this to work, I just created a new visual using &lt;FONT face="courier new,courier"&gt;pbiviz new&lt;/FONT&gt; and then removed all unnecessary code, but I'll paste my &lt;FONT face="courier new,courier"&gt;visual.ts&lt;/FONT&gt; below for you.&lt;/P&gt;&lt;P&gt;Things to bear in mind:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Chartutils needs to be installed as a dependency:&lt;BR /&gt;&lt;PRE&gt;npm i powerbi-visuals-utils-chartutils&lt;/PRE&gt;&lt;/LI&gt;&lt;LI&gt;Critical references are the&amp;nbsp;&lt;FONT face="courier new,courier"&gt;&lt;A href="https://github.com/microsoft/powerbi-visuals-utils-chartutils/blob/master/src/legend/legendInterfaces.ts#L68" target="_self"&gt;LegendData&lt;/A&gt; &lt;/FONT&gt;and&amp;nbsp; &lt;FONT face="courier new,courier"&gt;&lt;A href="https://github.com/microsoft/powerbi-visuals-utils-chartutils/blob/master/src/legend/legendInterfaces.ts#L57" target="_self"&gt;LegendDataPoint&lt;/A&gt;&lt;/FONT&gt;&amp;nbsp; interfaces, in terms of getting your data in there.&lt;/LI&gt;&lt;LI&gt;Despire what the definition says, you need the following properties setting for each &lt;FONT face="courier new,courier"&gt;LegendDataPoint&lt;/FONT&gt; to ensure it renders without erroring:&lt;UL&gt;&lt;LI&gt;&lt;FONT face="courier new,courier"&gt;label&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT face="courier new,courier"&gt;color&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT face="courier new,courier"&gt;identity&lt;/FONT&gt; - this requires building a &lt;A href="https://github.com/microsoft/PowerBI-visuals/blob/master/Visual/Selection.md" target="_self"&gt;Selection ID&lt;/A&gt; and doesn't seem to work if you leave it &lt;FONT face="courier new,courier"&gt;null&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT face="courier new,courier"&gt;selected&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT face="courier new,courier"&gt;markerShape&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;Invoking the &lt;FONT face="courier new,courier"&gt;drawLegend&lt;/FONT&gt; method will add a SVG element to the DOM. You will need to manage the sizing changes to your plot area after this is drawn.&lt;UL&gt;&lt;LI&gt;This can be done with the &lt;FONT face="courier new,courier"&gt;getMargins&lt;/FONT&gt; / &lt;FONT face="courier new,courier"&gt;getOrientation&lt;/FONT&gt; methods and adjusting your other elements accordingly.&lt;/LI&gt;&lt;LI&gt;You can refer to the source of the violin plot for some examples of how this has been done, although it uses the older SDK so isn't subject to some of the stuff going on here, but I'd suggest &lt;A href="https://bitbucket.org/dm-p/power-bi-visuals-violin-plot/src/1.2.0.3/" target="_self"&gt;keeping to the 1.2.0 code for reference&lt;/A&gt;; 1.3.0 gets a bit weird as it's manipulating the legend post-render.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;There's no error handling in the update method, so you'll need to ensure that you have a something in the Category field.&lt;/LI&gt;&lt;LI&gt;I've added comments at the appropriare location in the imports to show where I've started to add stuff in.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Here's how it looks for a simple data set:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 573px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/179470i6CC49D6CEE24CE98/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;And, dragging the viewport across will cause the chart to scroll, e.g.:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 224px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/179471iC5FA7BBFDB07C0E0/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here's the code from my &lt;FONT face="courier new,courier"&gt;visual.ts&lt;/FONT&gt;:&lt;/P&gt;&lt;PRE&gt;"use strict";

import "core-js/stable";
import "./../style/visual.less";
import powerbi from "powerbi-visuals-api";
import VisualConstructorOptions = powerbi.extensibility.visual.VisualConstructorOptions;
import VisualUpdateOptions = powerbi.extensibility.visual.VisualUpdateOptions;
import IVisual = powerbi.extensibility.visual.IVisual;
import EnumerateVisualObjectInstancesOptions = powerbi.EnumerateVisualObjectInstancesOptions;
import VisualObjectInstance = powerbi.VisualObjectInstance;
import DataView = powerbi.DataView;
import VisualObjectInstanceEnumerationObject = powerbi.VisualObjectInstanceEnumerationObject;
import { VisualSettings } from "./settings";

/** Added to support legend addition */
    import IVisualHost = powerbi.extensibility.visual.IVisualHost;
    import { legendInterfaces, legend } from 'powerbi-visuals-utils-chartutils';
    import createLegend = legend.createLegend;
    import ILegend = legendInterfaces.ILegend;
    import LegendDataPoint = legendInterfaces.LegendDataPoint;
    import LegendPosition = legendInterfaces.LegendPosition;
    import MarkerShape = legendInterfaces.MarkerShape;

export class Visual implements IVisual {
    private target: HTMLElement;
    private settings: VisualSettings;
    private legend: ILegend;
    private host: IVisualHost;

    constructor(options: VisualConstructorOptions) {
        console.log('Visual constructor', options);
        this.target = options.element;

        /** Assign visual host */
            this.host = options.host;

        /** Reserve element for legend */
            this.legend = createLegend(
                this.target,
                false,
                null,
                true, /* scrollable */
                LegendPosition.Top
            );
    }

    public update(options: VisualUpdateOptions) {
        this.settings = Visual.parseSettings(options &amp;amp;&amp;amp; options.dataViews &amp;amp;&amp;amp; options.dataViews[0]);
        console.log('Visual update', options);

        /** THIS ASSUMES THAT YOUR DATA VIEW WORKS, SO THERE'S NO ERROR HANDLING. YOU WILL AT LEAST 
         *  NEED A VALUE IN THE CATEGORY DATA ROLE TO CONTINUE */
            let categoryRole = options.dataViews[0].categorical.categories[0];

        /** We're now going to create an array of LegendDataPoint objects to feed into our drawLegend
         *  method below.
         *  We're arbitrarily assigning a colour from the host's palette (theme) as it's required. You 
         *  might want to sub this out with your own from your view model */
            let myLegendDataPoints: LegendDataPoint[] = categoryRole.values.map( 
                (c, i) =&amp;gt; (
                    {
                        label: &amp;lt;string&amp;gt;c,
                        color: this.host.colorPalette.getColor(&amp;lt;string&amp;gt;c).value,
                        identity: this.host.createSelectionIdBuilder()
                            .withCategory(categoryRole, i)
                            .createSelectionId(),
                        selected: false,
                        markerShape: MarkerShape.circle
                    }
                )
            );

        /** This actually draws the legend; note that although font settings aren't required, it will look 
         *  'wrong' if they're not supplied */
            this.legend.drawLegend(
                {
                    title: 'Test Legend',
                    fontSize: 10,
                    dataPoints: myLegendDataPoints
                },
                options.viewport
            );
    }

    private static parseSettings(dataView: DataView): VisualSettings {
        return VisualSettings.parse(dataView) as VisualSettings;
    }

    /**
     * This function gets called for each of the objects defined in the capabilities files and allows you to select which of the
     * objects and properties you want to expose to the users in the property pane.
     *
     */
    public enumerateObjectInstances(options: EnumerateVisualObjectInstancesOptions): VisualObjectInstance[] | VisualObjectInstanceEnumerationObject {
        return VisualSettings.enumerateObjectInstances(this.settings || VisualSettings.getDefault(), options);
    }
}&lt;/PRE&gt;&lt;P&gt;Hopefully this helps in some way.&lt;/P&gt;&lt;P&gt;Good luck,&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 21:02:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/746104#M20073</guid>
      <dc:creator>dm-p</dc:creator>
      <dc:date>2019-07-22T21:02:36Z</dc:date>
    </item>
    <item>
      <title>Re: Sliding legend</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/746328#M20075</link>
      <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/397"&gt;@dm-p&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you, Daniel, for such detailed explanation.&lt;/P&gt;&lt;P&gt;However, I still get error. Probably, because I'm using pbiviz version 2.3.0.&lt;/P&gt;&lt;P&gt;Main issue, I installed chartutils, but I got error at import.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Will it work without updating pbiviz version?&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Yerkhan&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jul 2019 04:48:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/746328#M20075</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-23T04:48:51Z</dc:date>
    </item>
    <item>
      <title>Re: Sliding legend</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/746331#M20076</link>
      <description>Not in this form, as it's written for v3 of the SDK. I perhaps made the wrong assumption, as the majority of questions are pertaining to that, so apologies for not checking this first.&lt;BR /&gt;&lt;BR /&gt;The source code I linked for the violin plot uses 2.5, which will also work for 2.3 if you're using that. You'll need to downgrade chartutils as well as the latest version has been updated to support v3 of the SDK.&lt;BR /&gt;&lt;BR /&gt;I can re-write the above but will need to do it tomorrow as I'm away from my desk until then and will need to reinstall 2.x to confirm the solution for you.</description>
      <pubDate>Tue, 23 Jul 2019 04:58:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/746331#M20076</guid>
      <dc:creator>dm-p</dc:creator>
      <dc:date>2019-07-23T04:58:12Z</dc:date>
    </item>
    <item>
      <title>Re: Sliding legend</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/747052#M20087</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I've re-done the above in 2.3 for you. The process is closer to the install guide but there are still some issues in getting it to work. Here's the run-down:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;Make sure that if you're running &lt;FONT face="courier new,courier"&gt;pbiviz start&lt;/FONT&gt;, then you've stopped it prior to installation as you'll get inconsistent results after package installation.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT size="4"&gt;Package Installation&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I had to downgrade until I could find one that will work. 1.7.0 will run, but colour seemed to stop working after 1.5, so run the following command to import:&lt;/P&gt;&lt;PRE&gt;npm i powerbi-visuals-utils-chartutils@1.5.1&lt;/PRE&gt;&lt;P&gt;The installed packages have a dependency on d3, which it does install, but make sure that the typings are installed for it:&lt;/P&gt;&lt;PRE&gt;npm i @types/d3@3.5 --save-dev&lt;/PRE&gt;&lt;P&gt;To confirm, after instantiating a new visual and installing packages, my &lt;FONT face="courier new,courier"&gt;package.json&lt;/FONT&gt; looks like this, so you could just copy/paste and then run &lt;FONT face="courier new,courier"&gt;npm i&lt;/FONT&gt; to sync:&lt;/P&gt;&lt;PRE&gt;{
  "name": "visual",
  "dependencies": {
    "powerbi-visuals-utils-chartutils": "^1.5.1",
    "powerbi-visuals-utils-dataviewutils": "1.2.0"
  },
  "devDependencies": {
    "@types/d3": "^3.5.42"
  }
}&lt;/PRE&gt;&lt;P&gt;&lt;FONT size="4"&gt;&lt;STRONG&gt;tsconfig.json&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Add the following to the &lt;FONT face="courier new,courier"&gt;files&lt;/FONT&gt; key in &lt;FONT face="courier new,courier"&gt;tsconfig.json&lt;/FONT&gt; before &lt;FONT face="courier new,courier" size="3"&gt;settings.ts&lt;/FONT&gt;:&lt;/P&gt;&lt;PRE&gt;    "node_modules/powerbi-visuals-utils-formattingutils/lib/index.d.ts",
    "node_modules/powerbi-visuals-utils-interactivityutils/lib/index.d.ts",
    "node_modules/powerbi-visuals-utils-svgutils/lib/index.d.ts",
    "node_modules/powerbi-visuals-utils-typeutils/lib/index.d.ts",
    "node_modules/powerbi-visuals-utils-chartutils/lib/index.d.ts",&lt;/PRE&gt;&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;files&lt;/FONT&gt; key looks like this in mine:&lt;/P&gt;&lt;PRE&gt;  "files": [
    ".api/v2.5.0/PowerBI-visuals.d.ts",
    "node_modules/powerbi-visuals-utils-dataviewutils/lib/index.d.ts",
    "node_modules/powerbi-visuals-utils-formattingutils/lib/index.d.ts",
    "node_modules/powerbi-visuals-utils-interactivityutils/lib/index.d.ts",
    "node_modules/powerbi-visuals-utils-svgutils/lib/index.d.ts",
    "node_modules/powerbi-visuals-utils-typeutils/lib/index.d.ts",
    "node_modules/powerbi-visuals-utils-chartutils/lib/index.d.ts",
    "src/settings.ts",
    "src/visual.ts"
  ]&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT size="4"&gt;pbiviz.json&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Add the following to the &lt;FONT face="courier new,courier"&gt;externalJS&lt;/FONT&gt; key in &lt;FONT face="courier new,courier"&gt;pbiviz.json&lt;/FONT&gt;:&lt;/P&gt;&lt;PRE&gt;    "node_modules/d3/d3.min.js",
    "node_modules/powerbi-visuals-utils-typeutils/lib/index.js",
    "node_modules/powerbi-visuals-utils-svgutils/lib/index.js",
    "node_modules/powerbi-visuals-utils-formattingutils/lib/index.js",
    "node_modules/powerbi-visuals-utils-interactivityutils/lib/index.js",
    "node_modules/powerbi-visuals-utils-chartutils/lib/index.js"&lt;/PRE&gt;&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;externalJS&lt;/FONT&gt; key looks like this in mine:&lt;/P&gt;&lt;PRE&gt;  "externalJS": [
    "node_modules/powerbi-visuals-utils-dataviewutils/lib/index.js",
    "node_modules/d3/d3.min.js",
    "node_modules/powerbi-visuals-utils-typeutils/lib/index.js",
    "node_modules/powerbi-visuals-utils-svgutils/lib/index.js",
    "node_modules/powerbi-visuals-utils-formattingutils/lib/index.js",
    "node_modules/powerbi-visuals-utils-interactivityutils/lib/index.js",
    "node_modules/powerbi-visuals-utils-chartutils/lib/index.js"
  ]&lt;/PRE&gt;&lt;P&gt;&lt;FONT size="4"&gt;&lt;STRONG&gt;visual.less&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;It shouldn't matter for this scenario, but to mirror the installation guide, make sure the following are present at the top of visual.less:&lt;/FONT&gt;&lt;/P&gt;&lt;PRE&gt;@import (less) "node_modules/powerbi-visuals-utils-interactivityutils/lib/index.css";
@import (less) "node_modules/powerbi-visuals-utils-chartutils/lib/index.css";&lt;/PRE&gt;&lt;P&gt;&lt;FONT size="4"&gt;&lt;STRONG&gt;visual.ts&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;The solution in the previous post is largely unchanged, except for:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The way dependencies are imported, e.g.:&lt;BR /&gt;&lt;PRE&gt;    import createLegend = powerbi.extensibility.utils.chart.legend.createLegend;
    import ILegend = powerbi.extensibility.utils.chart.legend.ILegend;
    import Legend = powerbi.extensibility.utils.chart.legend;
    import LegendData = powerbi.extensibility.utils.chart.legend.LegendData;
    import LegendIcon = powerbi.extensibility.utils.chart.legend.LegendIcon;
    import LegendPosition = powerbi.extensibility.utils.chart.legend.LegendPosition;
    import LegendDataPoint = powerbi.extensibility.utils.chart.legend.LegendDataPoint;&lt;/PRE&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT face="courier new,courier"&gt;LegendDataPoint&lt;/FONT&gt; doesn't use &lt;FONT face="courier new,courier"&gt;markerShape&lt;/FONT&gt; as a property and this is &lt;FONT face="courier new,courier"&gt;icon&lt;/FONT&gt; in this version, so double-check this part of the code if you're amending your local version (the compiler will error if not correct), e.g.:&lt;BR /&gt;&lt;PRE&gt;{
    label: &amp;lt;string&amp;gt;c,
    color: this.host.colorPalette.getColor(&amp;lt;string&amp;gt;c).value,
    identity: this.host.createSelectionIdBuilder()
        .withCategory(categoryRole, i)
        .createSelectionId(),
    selected: false,
    icon: LegendIcon.Circle
}&lt;/PRE&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Again just to be sure, here's the full visual.ts:&lt;/P&gt;&lt;PRE&gt;/** powerbi.extensibility.utils.chart.legend */
    import createLegend = powerbi.extensibility.utils.chart.legend.createLegend;
    import ILegend = powerbi.extensibility.utils.chart.legend.ILegend;
    import Legend = powerbi.extensibility.utils.chart.legend;
    import LegendData = powerbi.extensibility.utils.chart.legend.LegendData;
    import LegendIcon = powerbi.extensibility.utils.chart.legend.LegendIcon;
    import LegendPosition = powerbi.extensibility.utils.chart.legend.LegendPosition;
    import LegendDataPoint = powerbi.extensibility.utils.chart.legend.LegendDataPoint;

module powerbi.extensibility.visual {
    "use strict";
    export class Visual implements IVisual {
        private target: HTMLElement;
        private settings: VisualSettings;
        private legend: ILegend;
        private host: IVisualHost;

        constructor(options: VisualConstructorOptions) {
            console.log('Visual constructor', options);
            this.target = options.element;
    
            /** Assign visual host */
                this.host = options.host;
    
            /** Reserve element for legend */
                this.legend = createLegend(
                    this.target,
                    false,
                    null,
                    true, /* scrollable */
                    LegendPosition.Top
                );
        }

        public update(options: VisualUpdateOptions) {
            this.settings = Visual.parseSettings(options &amp;amp;&amp;amp; options.dataViews &amp;amp;&amp;amp; options.dataViews[0]);
            console.log('Visual update', options);
    
            /** THIS ASSUMES THAT YOUR DATA VIEW WORKS, SO THERE'S NO ERROR HANDLING. YOU WILL AT LEAST 
             *  NEED A VALUE IN THE CATEGORY DATA ROLE TO CONTINUE */
                let categoryRole = options.dataViews[0].categorical.categories[0];
    
            /** We're now going to create an array of LegendDataPoint objects to feed into our drawLegend
             *  method below.
             *  We're arbitrarily assigning a colour from the host's palette (theme) as it's required. You 
             *  might want to sub this out with your own from your view model */
                let myLegendDataPoints: LegendDataPoint[] = categoryRole.values.map( 
                    (c, i) =&amp;gt; (
                        {
                            label: &amp;lt;string&amp;gt;c,
                            color: this.host.colorPalette.getColor(&amp;lt;string&amp;gt;c).value,
                            identity: this.host.createSelectionIdBuilder()
                                .withCategory(categoryRole, i)
                                .createSelectionId(),
                            selected: false,
                            icon: LegendIcon.Circle
                        }
                    )
                );
    
            /** This actually draws the legend; note that although font settings aren't required, it will look 
             *  'wrong' if they're not supplied */
                this.legend.drawLegend(
                    {
                        title: 'Test Legend',
                        fontSize: 10,
                        dataPoints: myLegendDataPoints
                    },
                    options.viewport
                );
        }

        private static parseSettings(dataView: DataView): VisualSettings {
            return VisualSettings.parse(dataView) as VisualSettings;
        }

        /** 
         * This function gets called for each of the objects defined in the capabilities files and allows you to select which of the 
         * objects and properties you want to expose to the users in the property pane.
         * 
         */
        public enumerateObjectInstances(options: EnumerateVisualObjectInstancesOptions): VisualObjectInstance[] | VisualObjectInstanceEnumerationObject {
            return VisualSettings.enumerateObjectInstances(this.settings || VisualSettings.getDefault(), options);
        }
    }
}&lt;/PRE&gt;&lt;P&gt;At this point you can run &lt;FONT face="courier new,courier"&gt;pbiviz start&lt;/FONT&gt; and this will work as for the v3 example above.&lt;/P&gt;&lt;P&gt;Good luck!&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jul 2019 19:15:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/747052#M20087</guid>
      <dc:creator>dm-p</dc:creator>
      <dc:date>2019-07-23T19:15:28Z</dc:date>
    </item>
    <item>
      <title>Re: Sliding legend</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/763812#M20324</link>
      <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/397"&gt;@dm-p&lt;/a&gt;&amp;nbsp; Daniel,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for detailed answer! It was very helpful.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have some questions regarding it. I added it to my line chart, which has categorical dataview mapping, and can I pass to legend grouping of categorical data view? I tried using this:&lt;/P&gt;&lt;PRE&gt;let categoryRole = options.dataViews[0].categorical.values.grouped();&lt;/PRE&gt;&lt;P&gt;But it gave me error.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, I don't want to use selection id, if I leave it empty, I get error.&amp;nbsp;&lt;/P&gt;&lt;P&gt;And finally, even though scrollable parameter is true, I can't scroll:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 430px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/184364i788D39C3E42AD793/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;When I click on arrow, it doesn't work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Yerkhan&lt;/P&gt;</description>
      <pubDate>Mon, 12 Aug 2019 06:07:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/763812#M20324</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-08-12T06:07:54Z</dc:date>
    </item>
    <item>
      <title>Re: Sliding legend</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/764515#M20331</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I mentioned in &lt;A href="https://community.powerbi.com/t5/Developer/Sliding-legend/m-p/746104/highlight/true#M20073" target="_self"&gt;my earlier post&lt;/A&gt; that you will need to have a selection ID for each entry, otherwise the legend utility will not work. Unfortunately for your case you cannot provide a null value here so will need to provide something valid. It's highly likely that this is causing your legend to break.&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;</description>
      <pubDate>Mon, 12 Aug 2019 19:17:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/764515#M20331</guid>
      <dc:creator>dm-p</dc:creator>
      <dc:date>2019-08-12T19:17:27Z</dc:date>
    </item>
    <item>
      <title>Re: Sliding legend</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/764900#M20337</link>
      <description>&lt;P&gt;Hi&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;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Got it regarding selection id. How does regular line chart works? It has date as axis, category as grouping for data, and legend is built based on category. I wanted to recreate it, but with cumulative values.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Yerkhan&lt;/P&gt;</description>
      <pubDate>Tue, 13 Aug 2019 07:09:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/764900#M20337</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-08-13T07:09:24Z</dc:date>
    </item>
    <item>
      <title>Re: Sliding legend</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/766955#M20366</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I'm not entirely sure I follow - you can manage cumulative measures with the core line chart and DAX. Is there a specific feature you're trying to manage in your custom visual?&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;</description>
      <pubDate>Wed, 14 Aug 2019 22:03:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/766955#M20366</guid>
      <dc:creator>dm-p</dc:creator>
      <dc:date>2019-08-14T22:03:29Z</dc:date>
    </item>
    <item>
      <title>Re: Sliding legend</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/771487#M20466</link>
      <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/397"&gt;@dm-p&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't use DAX since I'm using live connection to OLAP cube. I wanted to recreate line chart, but make cumulative calculations inside of visual. However, by legend doesn't work, as I mentioned before.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Yerkhan&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2019 06:07:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/771487#M20466</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-08-21T06:07:39Z</dc:date>
    </item>
    <item>
      <title>Re: Sliding legend</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/771644#M20469</link>
      <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/397"&gt;@dm-p&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, when I click on arrow in scrollable legend in bar chart, text color of legend changes. By default it was black. I changed it to white using visual.less. When I scroll legend, it changes again to black.&lt;/P&gt;&lt;P&gt;How it can be changed?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Yerkhan&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2019 08:36:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/771644#M20469</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-08-21T08:36:21Z</dc:date>
    </item>
    <item>
      <title>Re: Sliding legend</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/772396#M20476</link>
      <description>&lt;P&gt;From the looks of things, there is something that happens with re-drawing the nav buttons when clicked that seems to ignore any styling or changes applied.&amp;nbsp;I made some attempts in one of my visuals to do something similar in the past (to change the shape of the icons), but found that it was more trouble that it was worth and abandoned my efforts.&lt;/P&gt;&lt;P&gt;If you want to do this in a maintainable way, then I think you'll need to create an idea with the custom visuals team to add support. You can refer to &lt;A href="https://community.powerbi.com/t5/Custom-Visuals-Development/Power-BI-Custom-Visuals-Community/m-p/667211#M2029" target="_self"&gt;this post in the Custom Visuals Development Discussion Forum&lt;/A&gt; for more details.&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;Regarding your other question, if you can't write DAX in-model, I would suggest requesting the owners of the OLAP cube add in such a measure for you - these tools are designed for such functionality and it is minimal work for them to manage and support. If the OLAP cube is SSAS, then SSAS Tabular uses DAX for its measures; SSAS Multidimensional can achieve the same via MDX. Solving in the semantic model is going to be the way to go.&lt;/P&gt;&lt;P&gt;Not to discourage learning how to develop custom visuals at all - I would personally love to have more people to collaborate with and learn from - but this is a very heavy approach to solving a problem that can be resolved upstream and is going to be several of hours' work from my side to document how such a solution could conceivably work (and much more from yours to develop). I'm a big subscriber to working smarter rather than harder. As it's outside the scope of the original question, I think it probably warrants its own thread if you specifically want to go through this.&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;However,&amp;nbsp;&lt;EM&gt;if&lt;/EM&gt; I were to do this, then I'd start by working with the standard &lt;FONT face="courier new,courier"&gt;categorical&lt;/FONT&gt; data mapping that comes with a new visual project, and set my view model hierarchy as &lt;FONT face="courier new,courier"&gt;measure[]&lt;/FONT&gt; &amp;gt; &lt;FONT face="courier new,courier"&gt;category[]&lt;/FONT&gt; &amp;gt; &lt;FONT face="courier new,courier"&gt;value[]&lt;/FONT&gt;. Once I've mapped my distinct measures and categories, as I iterate through the &lt;FONT face="courier new,courier"&gt;value&lt;/FONT&gt; array, I'd add to the previous value so that each subsequent value in the value array for each measure/category is a cumulative total.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2019 21:31:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/772396#M20476</guid>
      <dc:creator>dm-p</dc:creator>
      <dc:date>2019-08-21T21:31:51Z</dc:date>
    </item>
    <item>
      <title>Re: Sliding legend</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/772576#M20477</link>
      <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/397"&gt;@dm-p&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Firstly, I tried adding cumulative value to OLAP cube, however, it didn't result in required field.&lt;/P&gt;&lt;P&gt;Therefore, I started building custom visual. I managed to overcome issue with legend text color and changing position of legend.&lt;/P&gt;&lt;PRE&gt;view model hierarchy as measure[] &amp;gt; category[] &amp;gt; value[]&lt;/PRE&gt;&lt;P&gt;Could explain this a bit more?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Yerkhan&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 04:35:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/772576#M20477</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-08-22T04:35:17Z</dc:date>
    </item>
    <item>
      <title>Re: Sliding legend</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/774323#M20506</link>
      <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/397"&gt;@dm-p&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi again,&lt;/P&gt;&lt;P&gt;How can I make sliding legend for visual with table dataview mapping?&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got error at identity, using getSelectionIds.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Yerkhan&lt;/P&gt;</description>
      <pubDate>Fri, 23 Aug 2019 13:08:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/774323#M20506</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-08-23T13:08:27Z</dc:date>
    </item>
    <item>
      <title>Re: Sliding legend</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/3881781#M52093</link>
      <description>after a certain amount of items in the legend the legend becomes scrollable</description>
      <pubDate>Wed, 01 May 2024 08:13:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Sliding-legend/m-p/3881781#M52093</guid>
      <dc:creator>Dabush</dc:creator>
      <dc:date>2024-05-01T08:13:26Z</dc:date>
    </item>
  </channel>
</rss>

