cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
MagnusRosenPBI Regular Visitor
Regular Visitor

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

Accepted Solutions
MagnusRosenPBI Regular Visitor
Regular Visitor

Re: Change settings from within custom visual

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
MagnusRosenPBI Regular Visitor
Regular Visitor

Re: Change settings from within custom visual

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

Helpful resources

Announcements
New Kudos Received Badges Coming

New Kudos Received Badges Coming

Kudos to you if you earned one of these! Check your inbox for a notification.

Microsoft Implementation for Communities Wins Award

Microsoft Implementation for Communities Wins Award

Learn about the award-winning innovation that was implemented across Microsoft’s Business Applications Communities.

Power Platform World Tour

Power Platform World Tour

Find out where you can attend!

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (4,913)