Forum Discussion
Problem with My Custom Visual in Power BI
Hi luanlopes
How to Fix or Smooth it:
✅ 1. Debounce or Throttle update()
-
Implement a small delay (e.g., 50–200 milliseconds) inside your visual's
updatemethod. -
Only re-render after things have "settled."
Example:
private updateTimer: any = null;
public update(options: VisualUpdateOptions) {
if (this.updateTimer) {
clearTimeout(this.updateTimer);
}
this.updateTimer = setTimeout(() => {
this.render(options);
}, 100); // adjust delay as needed
}
private render(options: VisualUpdateOptions) {
// Your regular drawing logic here
}
Compare the Old and New Data View
-
Before re-rendering, check if the "real" state actually changed.
-
Example idea:
if (JSON.stringify(newDataView) !== JSON.stringify(this.previousDataView)) {
this.previousDataView = newDataView;
this.render();
}3. Detect "Clear Filter" actions smarter You can't directly detect "Clear filters" clicked.
BUT you can infer it because:-
If filters suddenly disappear (
categorical.valuesorcategorical.categories.valuesbecomes empty or null), -
and the old state had selections,
-
it probably means Clear Filters was clicked.
Sample pseudo-check:
const filtersCleared = previousStateHadFilters && currentStateHasNoFilters;
if (filtersCleared) {
// Handle it differently if needed
}Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!
-