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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
salamandra
New Member

Need help on custom visual format pane

Hi all,

I'm currently working on my line chart project with pbi custom visual. Then I stumble upon some problem with customizable line color.

I add color option like this in capabilities.json

salamandra_0-1692684482986.png

and update options according to the data with getFormattingModel()

 

public getFormattingModel(): powerbiVisualsApi.visuals.FormattingModel {
        const colorSelectorCard: powerbi.visuals.FormattingCard = {
            displayName: "Data Colors",
            uid: "dataColorsCard_uid",
            groups: [
                {
                displayName: undefined,
                uid: "dataColorsCard_group_uid",

                slices: [],
            }
            ]
        };
        if (this.lineDataPoint.length) {
            this.lineDataPoint.forEach((dataPoint, idx) => {
                (<powerbi.visuals.FormattingGroup>colorSelectorCard.groups[0]).slices.push(
                    {
                        uid: `dataColorsCard_group_colorSelector${idx}_uid`,
                        displayName: dataPoint.category,
                        control: {
                            type: powerbi.visuals.FormattingComponent.ColorPicker,
                            properties: {
                                descriptor: {
                                    objectName: "colorSelector",
                                    propertyName: "fill",
                                    selector: dataViewWildcard.createDataViewWildcardSelector(dataViewWildcard.DataViewWildcardMatchingOption.InstancesAndTotals),
                                    altConstantValueSelector: dataPoint.selectionId.getSelector(),
                                    instanceKind: powerbi.VisualEnumerationInstanceKinds.ConstantOrRule
                                },
                                value: { value: dataPoint.color }
                            }
                        }
                    });
            });

            colorSelectorCard.revertToDefaultDescriptors = [
                {
                    objectName: "colorSelector",
                    propertyName: "fill",
                }
            ];
        }
        return { cards: [ colorSelectorCard ] }
    }

 

Options is appear and adjustable as expect (I put in 2 line data).

salamandra_1-1692684903432.png

Nevetheless, the output objects from dataViews[0].categorical.categories[0]  is appear to be in the length of  value in categories instead of number of line data (660 instead of 2).

salamandra_2-1692685236650.png

 

This could probably lead to some bug in the future, so I want some help on how to shape the objects data to be equal to number of input line data not the categories length.

 

Thanks

0 REPLIES 0

Helpful resources

Announcements
Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

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

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.