microsoft / microsoft/powerbi-visuals-api
Update event still holding the table data even when everything is removed.
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 108
- Forks
- 48
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I've only just started with the custom visuals so I might have missed something but I've tried to my best research.
PBI Visuals API Version: 4.7.0
I'm trying to create simple custom visual that will be rendering the JSON data of a single selection. I cannot use the single dataViewMapping, hence using the table. For testing I have a simplest table with one column and one row that contains the JSON data.
capabilities.json:
"privileges": [],
"dataRoles": [
{
"displayName": "JSON Data",
"name": "jsonData",
"kind": "GroupingOrMeasure"
}
],
"dataViewMappings": [
{
"conditions": [{"jsonData": { "min": 1, "max": 1}}],
"table": { "rows": {
"for": {
"in": "jsonData"
}
}}
}
]
visual.ts:
public update(options: VisualUpdateOptions) {
this.settings = Visual.parseSettings(options && options.dataViews && options.dataViews[0]);
console.log('Update: ', options);
const dataView: DataView = options.dataViews[0];
const dataViewDatable: DataViewTable = dataView.table;
const dataViewRow: DataViewTableRow = dataViewDatable.rows[0];
console.log('Visual update', this.jsonViewerInstance);
if (this.jsonViewerInstance && this.jsonViewerInstance.json != JSON.parse(<string>dataViewRow[0])) {
this.renderJSON(dataViewRow[0]);
}
// You could've done this also using the
// this.visualSettings = VisualSettings.parse<VisualSettings>(dataView);
if (options.dataViews[0].metadata && options.dataViews[0].metadata.objects.jsonFormatterProperties.fontSize) {
this.parentElement.style.fontSize = options.dataViews[0].metadata.objects.jsonFormatterProperties.fontSize + 'px';
}
if (options.dataViews[0].metadata && options.dataViews[0].metadata.objects.jsonFormatterProperties.fontFamily) {
this.parentElement.style.fontFamily = <string>options.dataViews[0].metadata.objects.jsonFormatterProperties.fontFamily;
}
}
However, when I remove that single column from the visual's JSON Data property, the update is fired but the dataViews still contain the table data so I don't know when to clear the visual ?!

There is this odd type=36 event but I don't know what that refers to.
According the typings: https://github.com/microsoft/powerbi-visuals-api/blob/main/index.d.ts the type=36 is not even included?
Thank you for any pointers.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the update method in visual.ts and the table mapping in capabilities.json. Reproduce the update after removing the JSON Data column, inspect the resulting dataViews and the reported type=36 event, and compare them with the API typings in index.d.ts. Done when the cleared state can be identified reliably or the API behavior is documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100