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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Krunalbpatel
Helper III
Helper III

Create Custom visuals - Set bar color

Hi,

 

I am creating a custom Bar chart. I want to change the bar color from the color palette. Each bar should have a different color based on selection.

 

let colors = createColorPalette(host.colors).reset()

 

But I am getting the error --> "Property 'colors' does not exist on type 'IVisualHost'"

 

and also

 

selector: barDataPoint.selectionId.getSelection()

 

I am getting the error --> " Property 'getSelection' does not exist on type 'ISelectionId'"

 

 

1 ACCEPTED SOLUTION

@Krunalbpatel,

 

Things have changed. Re-download the Sample Bar Chart Repo, and modify barChart.ts as shown below.

    interface BarChartDataPoint {
        value: PrimitiveValue;
        category: string;
        color: string;
        selectionId: powerbi.visuals.ISelectionId;
    };
selector: barDataPoint.selectionId.getSelector()
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

3 REPLIES 3
v-chuncz-msft
Community Support
Community Support

@Krunalbpatel,

 

The API Version has been updated to 1.3.0. Based on my test, you may refer to the following corresponding code snippet.

let colorPalette: IColorPalette = host.colorPalette;
selector: barDataPoint.selectionId.getSelector()
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.

Hi @v-chuncz-msft,

 

I am using this code also but I am getting the following error

 

 error  TYPESCRIPT  /src/visual.ts : (82,13) Type 'powerbi.extensibility.IColorPalette' is not assignable to type 'power
bi.extensibility.visual.PBI_CV_8D244A15_FCEE_4355_A23C_3E763013AF73.IColorPalette'.
  Property 'reset' is missing in type 'IColorPalette'.

 

And This error has been resolved by changing

selector: barDataPoint.selectionId.getSelector()

@Krunalbpatel,

 

Things have changed. Re-download the Sample Bar Chart Repo, and modify barChart.ts as shown below.

    interface BarChartDataPoint {
        value: PrimitiveValue;
        category: string;
        color: string;
        selectionId: powerbi.visuals.ISelectionId;
    };
selector: barDataPoint.selectionId.getSelector()
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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.

Top Solution Authors