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

Custom Visual displayUnits drop down menu

Hi I am making my custom visual and need the display units drop down menu.....I suspect this is part of power bi utility that was packaged in?  but I cannot find any documentation.  Can anyone help?  Thanks.

2019_07_09_08_10_35_Window.png

1 ACCEPTED SOLUTION
dm-p
Super User
Super User

Hi @Anonymous 

Use a type in your capabilities.json as follows:

"type": {
    "formatting": {
        "labelDisplayUnits": true
    }
}

The corresponding class property in your settings.ts will be of type number, as the list value will pass in a number a valueFormatter can use in the value parameter of the ValueFormatterOptions.

Here's some examples from one of my custom visuals (we're looking at the labelDisplayUnits object):

Hopefully this gets you moving!

Daniel

 

EDIT: the formatting type also has support for fontSize and alignment, values which will add selectors for font size and graphics for left/centre/right alignment as in the properties pane. Here's the section of the JSON schema for capabilities, which documents the formatting object type.

DOUBLE EDIT: looks like fontFamily was added a while back, too; that'll be worth exploring at some point...





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




View solution in original post

3 REPLIES 3
dm-p
Super User
Super User

Hi @Anonymous 

Use a type in your capabilities.json as follows:

"type": {
    "formatting": {
        "labelDisplayUnits": true
    }
}

The corresponding class property in your settings.ts will be of type number, as the list value will pass in a number a valueFormatter can use in the value parameter of the ValueFormatterOptions.

Here's some examples from one of my custom visuals (we're looking at the labelDisplayUnits object):

Hopefully this gets you moving!

Daniel

 

EDIT: the formatting type also has support for fontSize and alignment, values which will add selectors for font size and graphics for left/centre/right alignment as in the properties pane. Here's the section of the JSON schema for capabilities, which documents the formatting object type.

DOUBLE EDIT: looks like fontFamily was added a while back, too; that'll be worth exploring at some point...





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




Anonymous
Not applicable

@dm-p  Thank you so much for your help!  Every time your suggestions/tutorial guided us to solution.  We just made our first custom visual KPI card.

Thank you!

 

 

Hi @Anonymous - that's great to hear! Onwards and upwards! 🙂





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




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.