Forum Discussion
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
"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);
}- v-viig8 years agoCommunity Champion
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
- murphycrosby8 years agoRegular Visitor
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.
- v-viig8 years agoCommunity Champion
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