Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi,
I want to change the bar color and axis label color. How can I change the color. I write the same code which is downloaded from the github.
This is my sample code to set the color in VisualTransform method
let defaultColor: Fill = {
solid: {
color: colorPalette.getColor(category.values[i] + '').value
}
}
barChartDataPoints.push({
category: <string>category.values[i],
value: <number>dataValue.values[i],
color: getCategoricalObjectValue<Fill>(category, i, 'colorSelector', 'fill', defaultColor).solid.color,
selectionId: host.createSelectionIdBuilder()
.withCategory(category, i)
.createSelectionId()
});
And This is the code in enumerateObjectInstances method
case 'colorSelector':
for(let barDataPoint of this.barDataPoints) {
objectEnumeration.push({
objectName: objectName,
displayName: barDataPoint.category,
properties: {
fill: {
solid: {
color: barDataPoint.color
}
},
},
selector: barDataPoint.selectionId
});
}
break;
But it is not working. It will remain the same color as set it by default. It is not updating the bar color.
If I write
selector: barDataPoint.selectionId.getSelection()
then I got the following error.
Property 'getSelection' does not exist on type 'ISelectionId'.
Can you please help me.
Solved! Go to Solution.
I've also replied your new thread. Follow the link below to update API version.
https://github.com/Microsoft/PowerBI-visuals/blob/master/tools/usage.md#updating-visuals-api
Hi @v-chuncz-msft,
From this thread thread I got my solution for changing bar color. But I am not able to change the axis label color. Same thing has happen it flashes only the same color has been applied again.
Regards,
Krunal Patel
I am not getting the exact solution that I want.
How color palette object has been declared?
let colorPalette: IColorPalette = host.colorPalette;
I am getting error "Property 'reset' is missing in type 'IColorPalette'" while I am declare this way
And If I declare other way like
let colorPalette= createColorPalette(host.colors).reset();
Then also I am getting the error "Property 'colors' does not exist in 'IvisualHost'"
I've also replied your new thread. Follow the link below to update API version.
https://github.com/Microsoft/PowerBI-visuals/blob/master/tools/usage.md#updating-visuals-api
Hi @v-chuncz-msft,
From this thread thread I got my solution for changing bar color. But I am not able to change the axis label color. Same thing has happen it flashes only the same color has been applied again.
Regards,
Krunal Patel
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
16 | |
2 | |
1 | |
1 | |
1 |
User | Count |
---|---|
26 | |
3 | |
2 | |
2 | |
2 |