Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply

Change settings from within custom visual

Hi

 

I have made a custom visual that is a type of linegraph for financial timeseries. I am working with dates as a category, the name for each series as a "group by" to get columns and the sum of numeric values as the measure. Basically I am following the categoryGroupedBySeries-pattern.

 

The thing I am trying to do is to find a good way to specify which series should be the "main" series, as i calculate a few things for the main series and compare with any other series also displayed (think Fund performance vs Index performance over a period).

 

The first thing i tried was to include a text setting where the user can specify the actual name of the series. This works but whenever the selection of series change so that the setting name is present in the data sent to the visual, it gets messy. I have to choose one name and work from there.

 

The second thing i tried is to include a boolean setting (named isMain) for each databound series (isMain=true means that the series is the "main" series). This also works with a few caveats. The problem i get is that I can set the isMain=true for several series when working with databound settings. I have tried to control this in the code. The basic control flow I use is this:

 

update-function runs ->

Visual parses data from dataView (which includes databound objects that I parse to get which series have isMain=true) (works) ->

Visual ensures that only one databound setting has isMain=true in the visual code (works) ->

The user can change which series is the "main" series by clicking within the visual (works) ->

Visual sends settings back to power bi through enumerateObjectInstances (fails)

 

I know that my enumerateObjectInstances-function works fine in the normal case (I can change color, width etc) but in that case the action starts with the user changing a setting which in turn send an update to the visual. In my case I have sent some setting to the visual, the user clicks in the visual (on the legend) and in that way the apparent "main" series is changed. The problem I have is that this change is not being propagated back to the powerbi service.

 

Is there something I can do in the custom visual typescript code to trigger a function call to the enumerateObjectInstances-function?

 

Best Regards

Magnus

1 ACCEPTED SOLUTION

After investigating a bit further it seems the solution is to use "IVisualHost.persistProperties".

 

Do I need to use a objectname/property that is defined in the capabilities file for this or can I simply create a new object named after my liking?

 

EDIT - It seems that the way to persist values was quite straight forward. You simply call IVisualHost.persistProperties with the correct settings and everything just works.

View solution in original post

1 REPLY 1

After investigating a bit further it seems the solution is to use "IVisualHost.persistProperties".

 

Do I need to use a objectname/property that is defined in the capabilities file for this or can I simply create a new object named after my liking?

 

EDIT - It seems that the way to persist values was quite straight forward. You simply call IVisualHost.persistProperties with the correct settings and everything just works.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.