mprozil / PlayAxis

Animate your Power BI visuals
MIT License
18 stars 9 forks source link

Option to make PlayAxis work cumulatively rather than time-unit snapshot? #9

Closed seedjay1 closed 3 years ago

seedjay1 commented 5 years ago

Great widget for PowerBI obviously, thank you!

It would be awesome for my use case if there were a way to make the widget work cumulatively.

Example: I perform installs daily all over the place, and those installs generate transactions afterwards. With the stock date filter, you can set it to slider-mode, and move ONLY the right endpoint left & right to track NEW installs/transactions against a FIXED left endpoint.

The way the PlayAxis widget works, it effectively sets left time unit endpoint = right time unit endpoint, and marches them BOTH forward in time units. So I see my installation base additions each day with it, but not the cumulative total prior.

(edit: yes, I could make my deployment table have a row every day after install than means effectively "yup still installed", but that makes a huge bloat in the deployment table size.)

Does that make sense?

iuriemaxim commented 5 years ago

Not clear if I understood your issue, but here is what I understood: PlayAxis is a custom slicer. Therefore it should be used to slice data, not to compute values (e.g. cumulative total prior). The computations should be made in a computed field (or in the database trough a view) and displayed in a card visual within the Power BI report. The PlayAxis will just slice the data and therefore the card visual will show the value from the computed filed (e.g.: "cumulative total prior"). The values that are displayed in the Play Axis are the values that are used for slicing the data, usually time (e.g.: Years 2016, 2017, 2018 or days 20/03/2019, 21/03/2019). The PlayAxis slicer cant show "cumulative total prior" (e.g.: 324 installations on 20/03/2019 and 328 installations on 21/03/2019). Use a card visual to show this value and compute the value within a view directly in the database.

Hope it helps

seedjay1 commented 5 years ago

Thanks for getting back to me. Let me try to explain my thinking better.

Think about the OEM PowerBI data slicer, set to Between mode. It has a drag-able left endpoint and a drag-able right point.

Imagine you keep the left endpoint fixed at 1/1/2000, and move ONLY the right endpoint 1 day to the right, repeatedly - 1/2, then 1/3, then 1/4, etc..

Then the calendar table range sequence consists of 1/1-1/2, 1/1-1/3, 1/1-1/4, etc..

Holding that left endpoint fixed and varying ONLY the right endpoint, is basically what I was talking about with the word "cumulative".

The PlayAxis slicer is like where the left endpoint MUST equal the right endpoint of the OEM slicer - so each date range consists of exactly 1 day.

My suggestion was to implement the option of holding the left data endpoint fixed, and only incrementing the right endpoint. With report measures coded at the daily level, the end result would thus be cumulative.

Does that make any more sense?

iuriemaxim commented 5 years ago

PlayAxis is intended for animation. That's why its name is starting with "Play". Therefore it should slice always by only one value. For example we are using PlayAxis for maps. When we hit play, the map is changing day by day (or year by year, depending if we have daily data or yearly data). It should not select multiple days/years because a map should represent data from only a certain day/year. You should look to another slicer as this one was intended for animation. The two buttons (left and right) are just allowing the user to manually to go forward or backward. But the main functionality is the "Play" button.

seedjay1 commented 5 years ago

Understood. I'm not communicating my thinking well, so I'll drop it. Thanks!

iuriemaxim commented 5 years ago

You communicated your thinking well. I think that the solution resides in the data, not in the slicer. Indeed the table size can be increasing substantially if this computation is done Power BI, But if the values will be computed in a SQL view and not in Power BI, than this may be a solution.

NoahPoundCake commented 5 years ago

I agree... Great widget for PowerBI obviously, thank you!

PLEASE..PLEASE.. Enhance the [Play Axis (Dynamic Slicer)] visual to be cumulative, and/or filtering.

Reading through the thread, if this can't be developed, then create JUST a time slicer with cumulative functionality.

imfm commented 3 years ago

This is a fantastic widget! I too would really like to see a cumulative animation. If this works as a slicer, then it should be trivial. Instead of iterating through each data point and hiding/disabling the previous one, just add the next one to what's already showing. I intended to try making this happen myself, but when I try to run pbiviz start on your code, I get an error - undefined message after Compile visualPlugin.ts. Not a very helpful message Microsoft. At any rate, I did my best to install all the dependencies, but I'm so new to this I don't really know what I'm doing and I get the impression this was built on an older API which I may not be able to replicate on my system.

imfm commented 3 years ago

I got it working.

On the playAnimation function, add an array variable to hold the selectionIds as you iterate through the items. The selectionManager.select function can take an array of selections ids. The second argument, multiSelect?: boolean has bizarre behavior if set to true. Set it to false, and it selects every item in the array. With that, the behavior of showing a cumulative animation can be achieved. Then it's just a matter of adding an option somewhere to switch back and forth.

Add an array of ISelectionId:

let activeIds: ISelectionId[] = [];

Then change this line:

this.selectionManager.select(this.viewModel.dataPoints[i].selectionId);

to this:

activeIds.push(this.viewModel.dataPoints[i].selectionId); this.selectionManager.select(activeIds,false);

mprozil commented 3 years ago

That's great @imfm , do you want to create a pull request with those changes so others can use it too?

imfm commented 3 years ago

That's great @imfm , do you want to create a pull request with those changes so others can use it too?

Yeah, I'm trying to figure out how to move the caption below the controls because it is getting cut off. And I also want to figure out how to add a toggle to switch back and forth. Then I'll submit one.

mprozil commented 3 years ago

Awesome! Let me know if you need any help. To create the toggle, if I understood what you are trying to do, you should add it to the capabilities.json. Check what already exists for "Auto Start".

seedjay1 commented 3 years ago

well this is exciting collaboration! awesome!

imfm commented 3 years ago

Awesome! Let me know if you need any help. To create the toggle, if I understood what you are trying to do, you should add it to the capabilities.json. Check what already exists for "Auto Start".

I added a variable "cumulative" to capabilities.json and mapped it out in playAxis.ts similar to what you did with autostart. "objects": { "transitionSettings": { "displayName": "Animation Settings", "properties": { "autoStart": { "displayName": "Auto Start", "type": { "bool": true } }, "loop": { "displayName": "Loop", "type": { "bool": true } }, "timeInterval": { "displayName": "Time(ms)", "type": { "integer": true } }, "cumulative": { "displayName": "Cumulative Animation", "type": { "bool": false } } } },

It's not giving me any errors, but I can't see it in powerbi.

mprozil commented 3 years ago

You should also add it to enumerateObjectInstances method here. If it still doesn't work you can make the pull request as is and I will have a look.

imfm commented 3 years ago

Yeah, it still didn't work. I know the variable is being set correctly because if I set the default value to true, it works as expected. But still no option to toggle it in powerbi. I'll make the pull request and hopefully you can add the finishing touches.

        switch(objectName) {            
            case 'transitionSettings': 
                objectEnumeration.push({
                    objectName: objectName,
                    properties: {
                        autoStart: this.visualSettings.transitionSettings.autoStart,
                        loop: this.visualSettings.transitionSettings.loop,
                        timeInterval: this.visualSettings.transitionSettings.timeInterval,
                        cumulative: this.visualSettings.transitionSettings.cumulative
                    },
imfm commented 3 years ago

You should also add it to enumerateObjectInstances method here. If it still doesn't work you can make the pull request as is and I will have a look.

Sorry, this is my first time collaborating on github and a pull request is not as straightforward I thought it would be. Do I need to create a new repository or something? How do I get you my modifications?

imfm commented 3 years ago

I think I figured it out. You should have a pull request now.

imfm commented 3 years ago

I fixed the property not showing in PowerBI. This: "type": { "bool": true } boolean under type in capabilities.json is apparently whether the property shows up, not a default value. I changed it from false to true and now it works. I committed the fix in my fork.

mprozil commented 3 years ago

Perfect. I've accepted your pull request. Thank you!

imfm commented 3 years ago

Perfect. I've accepted your pull request. Thank you!

Great! Will you be repackaging this and resubmitting to Microsoft?

imfm commented 3 years ago

well this is exciting collaboration! awesome!

Temporary release with cumulative animation is available at: https://github.com/imfm/PlayAxis/releases/tag/v1.0.0

Until @mprozil has a chance to repackage and submit to Microsoft. You will need to manually add the pbiviz file to Power BI. Instructions on the release page.

@mprozil if you have updated your development environment and can no longer compile, feel free to use my packaged version as release.

seedjay1 commented 3 years ago

Desired extended functionality confirmed in the temporary release!

Thank you both so much - I think this will be a very popular enhancement in the wild!

PlayAxisEnhanced

mprozil commented 3 years ago

Thank you @imfm and @seedjay1 for the help. I have packed the version with this option and made it available [here].(https://github.com/mprozil/PlayAxis/blob/master/dist/playAxis.pbiviz) I'm planning on submitting this new version to Microsoft although from my experience it may take a while until it's available to the end users. I will also tweet about this new feature. Send me you twitter user if you want to be credited :)

seedjay1 commented 3 years ago

you two are the ones who did it - i just complained - credit is all yours. :D

markhawker commented 3 years ago

This is great work, thank you. However, if you interact with the skip forward or skip back options it loses the cumulative functionality. Any ideas?

chinmaykhandalkar-rimowa commented 3 years ago

Amazing effort guys!