Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Using containers in a Custom Visual

Hi,

I am currently trying to use containers to group properties per measure group. 

Unfortunately, I can see the dropdown on the properties pane but its empty... nothing gets assigned to it.

Anyone using this feature that could provide an example? It would be great to have this sample on the documentation.

 

Thank you


Regards

LS

3 REPLIES 3
dm-p
Super User
Super User

Hi there,

Are you looking to have a dropdown to display the measures in your visual and then display properties based on selection, kind of like the core visuals? If so, last time this asked, it wasn't supported.

However... I do see that Power KPI is open source now, and this may have some of the functionality you're after. I agree that an example of this would be very helpful!

I don't have a lot of time to dive fully into this right now and I've been saving such an activity for a rainy day. I've done a quick analysis and followed some breadcrumbs in the code and this might guide you in the right direction:

I hope that this might be helpful in some capacity, and if you get moving, let us know how you get on! It would be great to see if someone else is able to get this stuff working.

Good luck,

Daniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




Indeed, my last attempt of dynamic dropdowns failed as I do believe it is still not supported: the result of the enumerateObjectInstances method doesn't parse metadata and dropdowns are defined as static metadata 😞

 

But you can create a loop to populate the same settings for multiple field values. I have create a method(s) to do this like this one: 

public dataShapesEnumerateObjectInstances(dataPoints: ChartDataPoint[]): VisualObjectInstance[] {
    let instances: VisualObjectInstance[] = [];
    dataPoints.forEach((dataPoint: chartDataPoint, index: number) => {
        instances.push({
            displayName: `${dataPoint.label} - line size`,
            objectName: "shapes",
            selector: { id: index.toString(), metadata: undefined },
            properties: {
                strokeWidth: dataPoint.lineSize
            }
        });
        instances.push({
            displayName: `${dataPoint.label} - line type`,
            objectName: "shapes",
            selector: { id: index.toString(), metadata: undefined },
            properties: {
                lineStyle: dataPoint.lineStyle // defined as enum inline with capabilities.json
            }
        });
    });
    return instances;
}

Call it in enumerateObjectInstances 

via instances = this.dataColorsEnumerateObjectInstances(this.data.dataPoints);

 
And define the metadata in capbilities.json:
"shapes": {
    "displayName": "Shapes",
    "properties": {
        "strokeWidth": {
            "displayName": "Stroke size",
            "type": {
                "numeric": true
            }
        },
        "lineStyle": {
            "displayName": "Line style",
            "type" : {
                "enumeration": [
                    {
                        "value": "0",
                        "displayName": "Dashed"
                    },
                    {
                        "value": "1",
                        "displayName": "Solid"
                    },
                    {
                        "value": "2",
                        "displayName": "Dotted"
                    }
                ]
            }
        }
    }
}
This should result in a (long) list of the same properties grouped per field value, in your case the content of the calculation groups.
 
-JP

I've created an idea for this, as there didn't seem to be one already. Not sure if it will get any traction, but if you'd like to vote, go nuts!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.