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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
NileshBhayani
Frequent Visitor

Dynamic slice color based on categories change functionality

I'm creating custom pie chart so in that i have to add slice color change functionality. 

I have prepared default color array for the categories and creating slice for formate penal.

 

Below is the code which i have added in setting.ts file

 

sliceSettings.sliceDropdownItems.forEach((item, idx) => {
  slices.push({
    uid: `slice_color_uid_${item.value}`,
    displayName: `${item.displayName} Color`,
    control: {
      type: powerbi.visuals.FormattingComponent.ColorPicker,
      properties: {
        descriptor: {
          objectName: 'slices',
          propertyName: 'sliceColor', 
        },
        value: {
          value: sliceSettings.sliceColorArray?.[idx] || ''
        }
      }
    },
    disabled: false
  });
});

 

but when I try to change the color I'm not able the get that changed color details so Please help me on that

 

capabilities.json

 

"slices": {
            "displayName": "Slices",
            "properties": {
                "selectedSlice": {
                    "displayName": "Selected Slice",
                    "type": { "enumeration": [] }
                },
                "sliceColor": {
                    "displayName": "Slice Color",
                    "type": { "fill": { "solid": { "color": true } } }
                }
            }
        },


I think, I have to set dynamic properties based on categories but I'm not able to find any solution to set dynamic properties.

 

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

Hi @NileshBhayani  ,
Thanks for reaching out to the Microsoft fabric community forum.

In the current setup, the capabilities.json file defines a single sliceColor property under the slices object, which applies uniformly rather than on a per-category basis. This structure lacks the flexibility to store and retrieve distinct formatting settings for each slice. As a result, while colour pickers may appear in the formatting pane, the visual cannot persist or retrieve category-specific colour selections at runtime. To enable this level of customization, we must shift from static to data-bound object properties, which allow Power BI to associate formatting settings dynamically with each data point in the visual.

Reference: GitHub - microsoft/powerbi-visuals-utils-formattingmodel: powerbi visuals formatting model helper ut...

If you find this post helpful, please mark it as an "Accept as Solution" and consider giving a KUDOS. Feel free to reach out if you need further assistance.
Thank you


View solution in original post

1 REPLY 1
v-nmadadi-msft
Community Support
Community Support

Hi @NileshBhayani  ,
Thanks for reaching out to the Microsoft fabric community forum.

In the current setup, the capabilities.json file defines a single sliceColor property under the slices object, which applies uniformly rather than on a per-category basis. This structure lacks the flexibility to store and retrieve distinct formatting settings for each slice. As a result, while colour pickers may appear in the formatting pane, the visual cannot persist or retrieve category-specific colour selections at runtime. To enable this level of customization, we must shift from static to data-bound object properties, which allow Power BI to associate formatting settings dynamically with each data point in the visual.

Reference: GitHub - microsoft/powerbi-visuals-utils-formattingmodel: powerbi visuals formatting model helper ut...

If you find this post helpful, please mark it as an "Accept as Solution" and consider giving a KUDOS. Feel free to reach out if you need further assistance.
Thank you


Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.