How to extract the filtered data
Sometimes, when analyzing data with the pivot table, you stumble on weird/unexpected results. Especially when narrowing down, we really want to know what exactly those remaining data points are.
Is there a way to get an array of only the filtered data shown in the pivot table? How could I myself apply the filters? Are there any helper functions that I can import and use on my initial data array?
You can get the data for a cell with the clickCallback. You pass something like this to PivotTableUI:
tableOptions: { clickCallback: function(e, value, filters, pivotData) { var names = []; pivotData.forEachMatchingRecord(filters, function( record ) { names.push(record.Meal); }); alert(names.join('\n')); }, }
This is from App.jsx in the examples directory in the github repo. The demo at https://react-pivottable.js.org/ uses it to do the popup for cells.
See https://github.com/plotly/react-pivottable/pull/29 and https://github.com/plotly/react-pivottable/issues/40 An example from the older pivottable.js https://pivottable.js.org/examples/mps_prepop.html
Hi, I new with pivottable. I was able to render it but I would like to start with a fix pivot using a particular data.key1 as row and data.key2 as column. Basically as you have @ https://react-pivottable.js.org/ Do you think you can share the code of your demo? at least the interesting part?
Thanks