cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
murphycrosby Frequent Visitor
Frequent Visitor

Need to add a Format Property per Measure

For each Measure in the dataset, I need to add a format property.  I've allowed multiple measures in the capabilities.json file, but I actually want an AxisObject per measure.  Therefore, I'd like the format to be Axis_1 with a Property 1 and a Property 2, then an Axis_2 with a Property 1 and a Property 2.  This way I can group them by measure rather than the alternative of grouping them by Property.

 

Here is my current Capabilities and enumerateObjectInstances (right now I'm just looping statically 2 times to try and get it to work).  I've tried different selector types with no luck.

 
    "objects": {
        "axisObject" : {
            "displayName": "Axis",
            "properties": {
                "property1": {
                    "displayName": "Property 1",
                    "type": {
                        "bool": true
                    }
                },
                "property2": {
                    "displayName": "Property 2",
                    "type": {
                        "bool": true
                    }
                }
            }
        }

 
switch( objectName ) {
    case 'axisObject':
        for(let i = 0; i < 2; i++) {
            objectEnumeration.push({
                objectName: objectName,
                displayName: objectName + "_" + i,
                properties: {
                    property1: this.settings.axisObject.property1,
                    property2: this.settings.axisObject.property2
                },
                    selector: null
            });
        }
        break;
};
 
4 REPLIES 4
murphycrosby Frequent Visitor
Frequent Visitor

Re: Need to add a Format Property per Measure

The only way I can get it to work the way I want, is to hard code them in the capabilities, and then don't push them on the 

objectEnumeration array unless the categorical value length is long enough.  However, that seems like a hack.
 
"objects": {
	"yaxisObject1": {
		"displayName": "Y-Axis 1",
		"properties": {
			"property1": {
				"displayName": "Property 1",
				"type": {
					"bool": true
				}
			},
			"property2": {
				"displayName": "Property 2",
				"type": {
					"bool": true
				}
			}
		}
	},
	"yaxisObject2": {
		"displayName": "Y-Axis 2",
		"properties": {
			"property1": {
				"displayName": "Property 1",
				"type": {
					"bool": true
				}
			},
			"property2": {
				"displayName": "Property 2",
				"type": {
					"bool": true
				}
			}
		}
	},
	"yaxisObject3": {
		"displayName": "Y-Axis 3",
		"properties": {
			"property1": {
				"displayName": "Property 1",
				"type": {
					"bool": true
				}
			},
			"property2": {
				"displayName": "Property 2",
				"type": {
					"bool": true
				}
			}
		}
	}
}
public enumerateObjectInstances(options: EnumerateVisualObjectInstancesOptions): VisualObjectInstance[] | VisualObjectInstanceEnumerationObject {
	console.log('enumerateObjectInstances', this.dataView);
	let objectName: string = options.objectName;
	let objectEnumeration: VisualObjectInstance[] = [];

	switch( objectName ) {
		case 'yaxisObject1':
			if(this.dataView.categorical.values.length > 0) {
				objectEnumeration.push({
					objectName: objectName,
					properties: {
						property1: this.settings.yaxisObject1.property1,
						property2: this.settings.yaxisObject1.property2
					},
					selector: null
				});
			}
			break;
		case 'yaxisObject2':
			if(this.dataView.categorical.values.length > 1) {
				objectEnumeration.push({
					objectName: objectName,
					properties: {
						property1: this.settings.yaxisObject2.property1,
						property2: this.settings.yaxisObject2.property2
					},
					selector: null
				});
			}
			break;
		case 'yaxisObject3':
		if(this.dataView.categorical.values.length > 2) {
				objectEnumeration.push({
					objectName: objectName,
					properties: {
						property1: this.settings.yaxisObject3.property1,
						property2: this.settings.yaxisObject3.property2
					},
					selector: null
				});
			}
			break;
	};

	return objectEnumeration;
	//return VisualSettings.enumerateObjectInstances(this.settings || VisualSettings.getDefault(), options);
}
Moderator v-viig
Moderator

Re: Need to add a Format Property per Measure

It seems you should specify a selector for each instance of VisualObjectInstance.

To find out more please take a look at this example.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

murphycrosby Frequent Visitor
Frequent Visitor

Re: Need to add a Format Property per Measure

That example only seems to show adding properties dynamically to a group.  I'm needing to dynamically add additional groups of properties.

 

Currently, I've defined 5 of the same groups of properties then just don't push them if I don't have a measure for it.  This makes my capabilities longer than it needs to be, and caps my number of measures to the number of properties defined in the capabilities.

Moderator v-viig
Moderator

Re: Need to add a Format Property per Measure

We would recommend to return an instance of VisualObjectInstanceEnumerationObject as a result of enumerateObjectInstances.

This interface describes containers and instances. To associate an instance with a particular container you would need to fill containerIdx of VisualObjectInstance.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

Helpful resources

Announcements
New Kudos Received Badges Coming

New Kudos Received Badges Coming

Kudos to you if you earned one of these! Check your inbox for a notification.

Microsoft Implementation for Communities Wins Award

Microsoft Implementation for Communities Wins Award

Learn about the award-winning innovation that was implemented across Microsoft’s Business Applications Communities.

Power Platform World Tour

Power Platform World Tour

Find out where you can attend!

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (1,145)