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

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.

Reply
Anonymous
Not applicable

Unable to read default color object

 

In my capabilities.json I defind an object called color. I'm trying to define it inside my custom visual using : 

             
 
startingColor: getValue<string>(options.dataViews[0].metadata.objects,'colors','startingColor',"#111111"),
 
 But I'm unable to read the default color, since the visual is not running untill I define a new color in the styling pane.
 
4 REPLIES 4
v-viig
Community Champion
Community Champion

Hello @Anonymous,

 

Power BI doesn't allow to get default color. However, you might define your own default color to return it to Power BI as a default.

You just need to apply your default color if there's no color in the metadata.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

Can you please let me know how to do it? How can I check whether the metadata available or not?

v-viig
Community Champion
Community Champion

Can you share implementation of getValue function that you use to get color from the metadata?

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

 

I figured it out. Thanks. I'm using the condition if (options.dataViews[0].metadata.objects) to check whether the user has made any changes in the format pane or not.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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