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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Star8Pam
Frequent Visitor

Colour Change when modify date slicer

Hi,

 

I created a custom visual in power BI that allowed to insert different types of chart in one plot. But when I insert the plot on the dashboard, I have some trouble with date slicer. I define a colour for ma data and I save it with:

 

let view = dataView[0].categorical;
let categories = view.categories[0];
let objects = categories.objects;
let value = view.values;

for (let i = 0, len = Math.max(value.length); i < len; i++) {
	viewModel.dataPoints.push({
		category: <string>value[i].source.displayName,
		colour: objects && objects[i] && DataViewObjects.getFillColor(objects[i], {
			objectName: "colorSelector",
			propertyName: "fill"
		}, null),
		selectionId: this.host.createSelectionIdBuilder()
			.withCategory(categories, i)
			.createSelectionId(),
	});
}

But when I change the date slicer, objects is null or undefined and colour is reset to default.

There is a solution to always save the color in object when slicer is modify.

 

Thanks for yours help.

0 REPLIES 0

Helpful resources

Announcements
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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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