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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
callum
Helper II
Helper II

Confused about objects...

Hello,

 

I'll try to explain my situation as clearly as possible. I'm building a visual to simulate the functionality of ThoughtWorks' Tech Radar. I therefore have four classes; Radar, Sector, Point and Ring. Radar is the "main" class for which is an instance is returned from my visualTransform method. And then a radar has a property called sectors, which is an array of Sector instances. Each Sector then contains many Points (which then has a ring!), although this last bit doesn't really matter for the question.

 

Anyway, you can see how each sector has a different colour. I'd like the user to be able to choose these colours. I want to store it in a property of a Sector called colours, i.e. when plotting the visual I would use sector.colour.

 

I took a leaf out of the sample bar chart guide and added this to my capabilities.json:

 

  "objects": {
    "colourSelector": {
      "displayName": "Sector colours",
      "properties": {
        "fill": {
          "displayName": "Colour",
          "type": {
            "fill": {
              "solid": {
                "color": true
              }
            }
          }
        }
      }
    }
  }

But I'm not sure how to proceed further. I changed my enumerateObjectInstances to:

 

 

public enumerateObjectInstances(options: EnumerateVisualObjectInstancesOptions): VisualObjectInstance[] | VisualObjectInstanceEnumerationObject {
    let objectEnumeration = [];

    switch (options.objectName) {
        case "colourSelector":
            this.radar.sectors.forEach(function (sector) {
                objectEnumeration.push({
                    objectName: options.objectName,
                    displayName: sector.name,
                    properties: {
                        fill: {
                            solid: {
                                color: sector.colour
                            }
                        }
                    },
                    selector: sector
                });
            });
            break;
    }

    return objectEnumeration;
}

But I clearly need to do something more. Specifically in the "selector" bit; I don't think passing in an actual Sector instance is correct, but the guide seems to just glance over what should be passed in without giving much detail. (For clarity: each sector is given a default colour, hence why sector.colour is used here)

 

With this, I do get the following in the Format pane:

Capture2.PNG

However I don't know how I can bind these values to sector.colour. Where do they go?

 

I hope this makes sense! Thanks in advance.

1 ACCEPTED SOLUTION
v-chuncz-msft
Community Support
Community Support

@callum,

 

You may check function getCategoricalObjectValue.

https://github.com/Microsoft/PowerBI-visuals/blob/f76ae919d9c9df83318e62e2bd7b24d185e8a32e/Tutorial/...

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-chuncz-msft
Community Support
Community Support

@callum,

 

You may check function getCategoricalObjectValue.

https://github.com/Microsoft/PowerBI-visuals/blob/f76ae919d9c9df83318e62e2bd7b24d185e8a32e/Tutorial/...

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors