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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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