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
moises_martinez
Frequent Visitor

How create property string in power bi custom?

Hi everyone!

 

I'm developing a new custom visual with power bi and I'm creating new properties, but I don't know how to create string properties.

 

For color I'm using type: { fill: { solid: { color: true } } } and for bool I'm using type: { bool: true } .

Any help will be good for me.

 

Thank in advance.

1 ACCEPTED SOLUTION
itayrom
Resolver II
Resolver II

String properties are defined as follows:

type: { text: true }

 

EDITED:

By the way, you can see how the property type descriptors are defined in the VisualContracts.d.ts file in the custom-visuals github project. More specifically, the ValueTypeDescriptor interface defines the primitive propery types and the StructuralTypeDescriptor interface defines structural types(such as the fill type). You can then look for examples in the project by searching it for values corresponding to the definition. For example, you can see that the definition of the text property type expects a boolean value. Therefore, if you search the project for "text: true", and there happens to be a visual using it, the search will take you there(For property types that expects objects, such as the fill property, you can search for pattens such as "fill: {").

View solution in original post

5 REPLIES 5
andrewnz
Advocate III
Advocate III

So that doesn't help at all. 

 

If I put:

"objects": {
        "selectedListType": {
            "displayName": "List Type",
            "properties": {
                "text": {
                    "displayName": "Textx",
                    "type": { "text": true}
                }
            }
        }
    }

I get nothing.

 

Telling me to go and search somewhere is also of little help if I have no idea of the location you are talking about. 

 

This is seemingly simple stuff but Microsoft you are making it so hard to understand the basics. You might follow the approach of Mr D3 (Mike Bostock) and offer a plethora of worked examples instead of a few comments which have no context. 

 

Getting a propert to retrun a string value seems SO simple. But where is the simple example that shows how? The solution? Don't have a text input field. Crazy.

 

 

 

 

I raised an issue on Github for this:

https://github.com/Microsoft/PowerBI-visuals-sampleBarChart/issues/3#issuecomment-253744763

 

and Microsoft did reply:

"This is a known issue on the debug visual.
We are aware of it"

 

Seems we weren't all totally mad after all 🙂

 

I was just about to write a question for this.

 

I also can't solve this, I have followed the example here:

https://blogs.msdn.microsoft.com/tsmatsuz/2016/09/27/power-bi-custom-visuals-programming/

 

which at least explains it a bit unlike the current MS documentaiton!

 

I'll let you know if I get it working.....

 

 

Iam not really sure the question is answered already.

 

So here my Example Code: 

"start": {
                            "displayName": "Start",
                            "description": "Start Position",
                            "placeHolderText": "data.createDisplayNameGetter('Visual_Precision_Auto')",
                            "type": { "text": true },
                            "suppressFormatPainterCopy": true
                    },

That working fine. Do you implement the function behind that object?

You need to implement the getValueFunction:

start: getValue<string>(objects, 'categoryAxis', 'start', defaultSettings.categoryAxis.start),
          

And in theenumerateObjectInstances. After that you should see the object in the formatoptions.

itayrom
Resolver II
Resolver II

String properties are defined as follows:

type: { text: true }

 

EDITED:

By the way, you can see how the property type descriptors are defined in the VisualContracts.d.ts file in the custom-visuals github project. More specifically, the ValueTypeDescriptor interface defines the primitive propery types and the StructuralTypeDescriptor interface defines structural types(such as the fill type). You can then look for examples in the project by searching it for values corresponding to the definition. For example, you can see that the definition of the text property type expects a boolean value. Therefore, if you search the project for "text: true", and there happens to be a visual using it, the search will take you there(For property types that expects objects, such as the fill property, you can search for pattens such as "fill: {").

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.