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.
Hi. I've been working on a simple little visual to try and learn the ropes here and seem to keep running into problems getting the custom properties I define to populate the format pane. Any help with this issue would be appreciated!
Here's some code for context on my project:
capabilities.json objects:
"card": {
"displayName": "Card Settings",
"properties": {
"titleText": {
"displayName": "Title Text",
"type": {
"text": true
}
},
"titleColor": {
"displayName": "Title Color",
"type": {
"fill": {
"solid": {
"color": true
}
}
}
},
"titleSize": {
"displayName": "Title Font Size",
"type": {
"integer": true
}
},
"contentColor": {
"displayName": "Content Color",
"type": {
"fill": {
"solid": {
"color": true
}
}
}
},
"contentSize": {
"displayName": "Content Font Size",
"type": {
"integer": true
}
},
"flashColor": {
"displayName": "Flash Color",
"type": {
"fill": {
"solid": {
"color": true
}
}
}
},
"flashType": {
"displayName": "Flash Type",
"type": {
"enumeration": [
{
"displayName": "None",
"value": "none"
},
{
"displayName": "Blip",
"value": "blip"
}
]
}
}
}
}
settings.ts:
export class CardSettings {
public titleText: string = '';
public titleColor: string = "#ffffff";
public titleSize: number = 11;
public contentColor: string = "#ffffff";
public contentSize: number = 11;
public flashColor: string = "#ffffff";
public flashType: string = "none";
}
export class VisualSettings extends DataViewObjectsParser {
public settings: CardSettings = new CardSettings();
}
and enumerateObjectInstances in visual.ts:
public enumerateObjectInstances(
options: EnumerateVisualObjectInstanceOptions
😞 VisualObjectInstance[] | VisualObjectInstanceEnumerationObject {
console.log('enumerating...');
return VisualSettings.enumerateObjectInstances(this.settings || VisualSettings.getDefault(), options);
}
where this.settings = <VisualSettings>VisualSettings.parse(options.dataViews[0]) in update().
edit: made a mistake copying some code.
Solved! Go to Solution.
Hi @capuace
Your issue is this part of your code, in settings.ts:
export class VisualSettings extends DataViewObjectsParser {
public settings: CardSettings = new CardSettings();
}
Try changing to:
export class VisualSettings extends DataViewObjectsParser {
public card: CardSettings = new CardSettings();
}
The name of your class property needs to match the object name in your capabilities.json (you've defined as card in line 1 of your capabilities.json code) for it to enumerate correctly.
This also needs to be the same for your CardSettings properties, but these look OK 🙂
Good luck!
Daniel
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)
Hi @capuace
Your issue is this part of your code, in settings.ts:
export class VisualSettings extends DataViewObjectsParser {
public settings: CardSettings = new CardSettings();
}
Try changing to:
export class VisualSettings extends DataViewObjectsParser {
public card: CardSettings = new CardSettings();
}
The name of your class property needs to match the object name in your capabilities.json (you've defined as card in line 1 of your capabilities.json code) for it to enumerate correctly.
This also needs to be the same for your CardSettings properties, but these look OK 🙂
Good luck!
Daniel
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)
That did it. Thanks so much!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
16 | |
2 | |
2 | |
1 | |
1 |
User | Count |
---|---|
21 | |
2 | |
2 | |
2 | |
2 |