dm-p / powerbi-visuals-smlc

Small Multiple Line Chart Custom Visual for Power BI
MIT License
14 stars 9 forks source link

[ENHANCEMENT] Background conditional formatting #20

Open jotapece opened 4 years ago

jotapece commented 4 years ago

Hello. It would be great if you add the feature "Backgroud Conditional Formatting" for each small chart based in aditional measure.

graph

For example: In this graph I'm comparing costs and sales in different proyects. If could only set the bakground chart color with "%Result" measure it will be perfect. Red for bad and green for good. Maybe color scalling too.

I hope I explained myself.

Thanks in advance.

dm-p commented 4 years ago

Hi, and thanks very much for using the visual ,and I really appreciate the feedback. Apologies for the delay in coming back - I've had to have a big think about this one.

I think this would be straightforward if we had access to the same expression-based formatting options as core visuals in custom visuals, but unfortunately not. I have some questions pending with MS to see if there's anything we're likely to get here for custom visuals, as if we can get similar functionality, it may mitigate some of the challenges we potentially face below if not.

If we can't get access to conditional formatting any time soon, initial thoughts would be that we create a data role (e.g. Background Colour, like Axis or Small Multiple) that can be brought in to the visual's data view. Provided that the unique values of this result of this match the grain of the small multiple field value - although we have to map it down to the lowest level (which is Small Multiple > Axis > Measure) - then this could theoretically work.

Each additional type of 'measure-driven' value we add, decreases the number of available unique data points available by up to half, so if we want to add in colour-scaling as well, then this starts to get tricky if the user wants the maximum of 100 small multiples x 300 axis values. So there will be a trade-off to adding measure-based formatting, which we will have to accept as report designers, as our upper-limit of data points is constrained by MS.

As I've had another enhancement request for something similar, but not quite the same - potentially resulting in a need for 5 such measures - I need to have a think about how we can expose as many extensible, measure-driven properties that will give the most flexibility for report designers, while allowing as many data points as possible.

I believe that the best option here would be to push this down to a DAX measure, similar to how the core visuals handle expression based formatting. It won't be as elegant as the core visuals due to not having access to the data model, or expression editor dialog in the custom visuals SDK but will mirror the "Power BI way" as much as possible.

I'll wait and see if I can get some news on the questions with MS before I start any work on this as now the visual is certified, it takes a really long time to get updates approved and if I implement it wrong then it's harder to fix as visuals also need to be upgrade-safe for reports. I'll be happy to send you a beta version for thoughts once I start work though.

dm-p commented 4 years ago

There's no confirmation from MS as to whether conditional formatting will be available any time soon in the custom visuals SDK.

So, I've spent some time to look further into how this can be approached as-is, and if we want to provide a measure to manage a "conditional" background then it will be bound to the lowest-level of grain, which means that it will evaluate in the current Small Multiple / Axis context. So, if you want to colour the background consistently for the whole small multiple, you'll need to write an appropriate measure to ignore the row context.

However, this leads to some potentially interesting use cases like this example (where we colour the background blue if cooler than average temp and red if above):

image Would this be an acceptable implementation that you could work with, @jotapece ?