Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] VisualUpdateType is incorrect in options.type of the update function #528

Open
luizzappa opened this issue Nov 20, 2024 · 2 comments

Comments

@luizzappa
Copy link

luizzappa commented Nov 20, 2024

Issue Description:

There seems to be a bug in the options.type (from the VisualUpdateOptions object) passed to the update function of the IVisual class.

While implementing logic to handle different update types using the VisualUpdateType flags (#422 (comment)), I noticed inconsistent behavior, especially when changing styles.

Steps to Reproduce:

Implement the following update function:

public async update(options: VisualUpdateOptions) {
  console.log('options.type', options.type);

  if (VisualUpdateType.Data === (options.type & VisualUpdateType.Data)) {
    console.log('data update');
  }
  if (VisualUpdateType.Resize === (options.type & VisualUpdateType.Resize)) {
    console.log('resize update');
  }
  if (VisualUpdateType.ViewMode === (options.type & VisualUpdateType.ViewMode)) {
    console.log('view mode update');
  }
  if (VisualUpdateType.Style === (options.type & VisualUpdateType.Style)) {
    console.log('style update');
  }
  if (VisualUpdateType.ResizeEnd === (options.type & VisualUpdateType.ResizeEnd)) {
    console.log('resize end update');
  }
  if (VisualUpdateType.FormattingSubSelectionChange === (options.type & VisualUpdateType.FormattingSubSelectionChange)) {
    console.log('formatting sub-selection change update');
  }
  if (VisualUpdateType.FormatModeChange === (options.type & VisualUpdateType.FormatModeChange)) {
    console.log('format mode change update');
  }
  if (VisualUpdateType.FilterOptionsChange === (options.type & VisualUpdateType.FilterOptionsChange)) {
    console.log('filter options change update');
  }
  if (VisualUpdateType.All === (options.type & VisualUpdateType.All)) {
    console.log('all updates');
  }
}

Change any style in the visual:

  • First change: The console logs a formatting sub-selection change update event, as expected.
  • Subsequent changes: The console logs a data update event, which seems incorrect.

Image

Expected Behavior:

The event returned in options.type should consistently reflect the change as formatting sub-selection change update for all style modifications, instead of switching to data update.

Environment:

SDK Version: 5.11.0
Browser/Platform: Edge/Windows 11

@adiletelf
Copy link

adiletelf commented Nov 21, 2024

@luizzappa That's strange. I copied your code and I'm getting only data update.

Also, when I toggle "General -> Title" setting it's also adding/removing a title, which causes the visual to shift/resize. It also shows data update and Resize/Resize End, which sounds logical.

What version of powerbi-visuals-api do you use?

@luizzappa
Copy link
Author

Hi @adiletelf ,

I am using powerbi-visuals-api version 5.11.0.

I tested this by cloning the example repository for the Circle Card visual and noticed that, for the behavior in question to occur, the following options in capabilities.json need to be enabled:

"supportsLandingPage": true,
"supportsEmptyDataView": true

I have a question regarding how the visual's update API works. Perhaps I misunderstood, but I would like to confirm:
Is an update to a visual property (such as changing a color) always treated as a "Data" update? Is it not possible to distinguish between an update involving adding/removing columns/measures from the visual and a change to properties only?

Context of my use case

I am using the fetch more data API, but data loading is quite slow, taking around 30 seconds. Currently, whenever a user changes a property of the visual — such as a color or another layout configuration — the visual reloads all the data, which makes customizing layout settings very cumbersome for the end user.

I expected to use the VisualUpdateType values (such as Style or FormattingSubSelectionChange) to distinguish between:

  • Updates related to the formatting/style of the visual (e.g., color or size changes)
  • Updates to the data received by the visual.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants