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?