Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

📣 Dash Pivottable Released

Thanks for sharing it, it’s much clearer now! Unfortunately, the underlying react library (react-pivottable) does not support multiple average-aggregator, so I don’t think it’s possible to do this without modifying how pivottable.js works behind the scene.

One hypothetical way to approach this with Dash would be to generate two pandas dataframe that would take the format you’d like (each with a different “Totals” column, but same index), and merge them. Then, render the result with something like DataTable. This approach will likely not be able to directly incorporate dash-pivottable though.

Hi @xhlu - thanks for the feedback. I hadn’t thought about this as an option as I preferred to keep everything in the dynamic pivot table object. Once I export data away from that into a ‘standard’ Dash Table I will lose the pivot-table elements (e.g. swapping columns about) and equally, I doubt I will be able to ‘nest’ a Dash Table within the pivot table correctly (if that is even possible). Ideally these on-the-fly subtotal calcs and expandable sub-lists would be a feature of the pivottable library itself (e.g. the way the average/grand totals can be calculated from your input data, without first running those calcs yourself). Something for me to learn and attempt when I have time! Thanks again for the release!

This makes sense, thanks for explaining this @papalazorous! Since this is related to how react-pivottable renders the tables, we would have to add a renderer option upstream before being able to make a new release of dash-pivottable. I think a good first step would be to raise an issue in the react-pivottable repo, and perhaps take a look at the source code if you are comfortable with JS/React. Feel free to tag me and @nicolaskruchten if needed!

1 Like

Hi Xhlu, Very nice tool. I am struggling to integrate Dash-Pivottable in a Django Web App. As you know, it is possible to integrate a Dash app in a Django Website with the library DjangoDash. But when I try to integrate Dash-Pivotable (dash.Dash instead), it doesnt work. Please any idea? thanks

@xhlu, is there a way to prevent certain data cuts from being graphed? For instance, if a pivot cut results in a sample size less than N, can there be a way to avoid graphing?

Dash Pivottable doesn’t use any Flask-specific features, so I’m not totally sure what the problem is. Have you tried other component libraries (like dash bootstrap components) with Django Dash? It would be great to have a reproduceable demo (either a gist or formatted with ```) with the simplest possible django app and a simple dash-pivottable, so the problem can be easily isolated and help other users in the future!

To avoid graphing, you would likely need to write a callback that only renders the pivottable when a certain condition is met. Alternatively, if you are comfortable with JavaScript, you could

  • clone the repo and modify the source code to implement custom rendering logic based on specific needs
  • use client-side callback to stop the graph from being rendered on the JS side when your sample size is smaller than N

Thanks for the reply. I didn’t invest much time into it yet, but from the look of it, it didn’t seem like there were any callbacks that could stop a render, rather the component looked like it just worked once it was defined. The only callbacks I saw in the was to show some debugging information.

You might be able to update the rendererName prop based on the input data, but I can’t guarantee whether it would work well since I haven’t ran into a use case that required me to control the rendering based on a specific UI configuration.

I’m currently having issues with the parameter valueFilter, any attribute and attribute-values (True/False) deselects them from the filter on load. Would be great if there is a way to fix this issue such that I can only select the desired filtered values of the attribute.

valueFilter={‘Status’: {‘Completed’: True}} <- deselects the value of “Completed”

I like this pivot table element. Thanks for taking the time to develop and share. Is it possible to change the color scheme or other styling options? Also, when I run this, I get some text printed at the bottom of the table, and I see the same text in some of the example videos. Is it possible to have this output hidden? Thanks!

You can remove the callback that display the text.

As for style, you could modify this stylesheet and put it in your assets folder to override the style.

Thanks for your help!

I have been able to style the elements of the pivot table quite successfully, but what about changing colors of the heatmaps or the default plotly graphs? Thanks again

To modify the plotly graphs you will likely have to change the underlying Plot, so you might have to dive into the dash-pivottable source code and build your own version; the instructions are in the file inside the repo.