plotly / dash-pivottable Goto Github PK
View Code? Open in Web Editor NEWreact-pivottable in Dash
License: MIT License
react-pivottable in Dash
License: MIT License
Currently, you can capture the ValueFilter property as input, but changes to filters aren't passed back to the app.
DE user would like to use this property to trigger a callback and access the updated values.
Hello,
I see in the help of https://github.com/plotly/react-pivottable/ that a keyword vals in PivotData layer exists. Could you please update this lib so that we could use this keyword as well ?
Thanks a lot !
Coconuts
Is it possible hide the pivot table/UI controls, keeping only the pivot table/chart? I saw Nicholas's reply to the same question on the react-pivottable project but after changing <PivotTableUI ... />
to <PivotTable ... />
in PivotTable.react.js and generating a new PivotTable.py, the web page fails to load.
I would like to implement a weighted average using a fixed column as the weight value. That is, I could specify in advance that I want a specific column to serve as the weight. I am happy to alter the source of either dash-pivottable or react-pivottable but I'm not sure where to begin.
Does someone have a suggestion of how to or an example of implementing custom aggregation functions?
Thanks,
Matt
it is possible to limit the chart options to only table ?
Would it be possible to get box plots in the list of displayable analyses?
I need to get valueFilter which changed by user
But instead got {}
from dash import html, Output, Input, State
import dash_pivottable
app = dash.Dash(__name__)
server = app.server
import dash_bootstrap_components as dbc
app.layout = html.Div(children=[
dbc.Button('Press',id='button'),
html.Div(id="my-div",children=
[
dash_pivottable.PivotTable(id="pivot",
data=[
['Animal', 'Count', 'Location'],
['Zebra', 5, 'SF Zoo'],
['Tiger', 3, 'SF Zoo'],
['Zebra', 2, 'LA Zoo'],
['Tiger', 4, 'LA Zoo'],
],
cols=["Animal"],
rows=["Location"],
vals=["Count"],
valueFilter={}
)]
)])
@app.callback(
Output("my-div", 'children'),
Input('button', 'n_clicks'),
State("pivot","cols"),
State("pivot", "rows"),
State("pivot", "vals"),
State("pivot", "valueFilter"),
)
def refresh(n_clicks,cols,rows,vals,filter):
print(filter)
print(f"Click={n_clicks}")
ret=html.Div(children=dash_pivottable.PivotTable(
id=f"pivot",
data=[
['Animal', 'Count', 'Location'],
['Zebra', n_clicks, 'SF Zoo'],
['Tiger', n_clicks, 'SF Zoo'],
['Zebra', n_clicks, 'LA Zoo'],
['Tiger', n_clicks, 'LA Zoo'],
],
cols=cols,
rows=rows,
vals=vals,
valueFilter=filter
),id=f"pivot_div_{n_clicks}",)
return ret
if __name__ == "__main__":
app.run_server(debug=True)
Seems like when you run npm install
, "prepublish": "npm run validate-init"
gets called, which in turns causes this to be called: "validate-init": "python _validate_init.py"
.
Since python3
is not included with the node
image of CircleCI, it's annoying to create a venv in python 2 and run _validate_init.py
just for this. We might consider removing _validate_init.py
from prepublish in the future.
Hi,
This is handy and end user will probably ask for how to export the pivoted data. Is export to excel an option? Or it depends on react-pivotable to implement certain interface?
First of all, this thing is AWESOME!! Thank you so much!!
Right now, you have the setup commands to be:
$ git clone https://github.com/xhlulu/dash_pivottable.git
$ cd dash_pivottable
$ virtualenv venv
$ venv/Scripts/activate
$ pip install -r requirements.txt
$ python usage.py
BUT, I had some issues with this, and it wasn't getting past the third step. In the end, I needed to run these instead:
$ git clone https://github.com/xhlulu/dash_pivottable.git
$ cd dash_pivottable
$ virtualenv venv
$ source venv/bin/activate # Just change this line a bit
$ pip install -r requirements.txt
$ python usage.py
# Then, to deactivate, just
$ deactivate
And, of course for future uses:
$ cd dash_pivottable
$ source venv/bin/activate
$ python usage.py
# Do stuff
$ deactivate
I'm running on MacOS with Mojave, vers 10.14.3.
Thanks again!
It seems "python setup.py" doesn't work. Thanks!
I use dash_pivottable in a multiple tabs DASH application, but the filter set in pivot is gone after tab switching. I have tried dcc.tabs persistence=True, persistence_type='session'/'local'/'memory', but still cannot retain filter config after tab switching. The config of cols, rows, value or aggregatorName can be retained after tab switching, only filter is gone. Is there any way to retain the filter please?
Whether or not you set a value to True or False, it is eliminated from the active display:
From the sample:
valueFilter={'Day of Week': {'Thursday': False}}
leads to the same behavior as:
valueFilter={'Day of Week': {'Thursday': True}}
Perhaps I am not using this correctly? Thanks for sharing this excellent project
Hi, is there a way to exclude Totals column and row, and set a customized order of data in the pivot table?
Thanks!
I have a fork of Nicolas pivottable enhanced by the grouping capability.
You can see the details here: https://github.com/jjagielka/pivottable-grouping
Can you consider adding that fork to your dash-pivottable?
By default, values are formatted with two decimal places and the thousands separator. DE client would like the option to specify the format in the component construction.
The dash_pivottable.dev.js
file appears currently unused by either the Python or R packages, and is approximately 20 MB in size.
If possible, I'd suggest only building this additional JS via webpack when needed. For example, in dash-renderer
's package.json
we have
"build:js": "webpack --build release",
"build:dev": "webpack --build local",
which we use to control whether source maps are generated as well.
This recently caused friction with submitting the package to CRAN:
Thanks, we see:
Size of tarball: 5900811 bytes
Not more than 5 MB for a CRAN package, please.
Please fix and resubmit.
If we're able to make this change, the uncompressed R package size will plummet to 3 MB from over 20 MB, and the compressed archive will be approximately 1 MB.
The vals
property is not updated when accessed through a callback (unlike other properties such as cols
and rows
).
This would be really useful to maintain state between updates to the data of the pivot table. Currently, vals
always has the original value.
Run the following code and change the quantity being plotted from "Total Bill" to "Tips". The output vals
quantity will not change and will continue to report "Total Bill".
import dash
from dash.dependencies import Input, Output
import dash_html_components as html
import dash_pivottable
from data import data
app = dash.Dash(__name__)
app.title = 'My Dash example'
app.layout = html.Div([
dash_pivottable.PivotTable(
id='table',
data=data,
cols=['Day of Week'],
colOrder="key_a_to_z",
rows=['Party Size'],
rowOrder="key_a_to_z",
rendererName="Grouped Column Chart",
aggregatorName="Average",
vals=["Total Bill"],
valueFilter={'Day of Week': {'Thursday': False}}
),
html.Div(
id='output'
)
])
@app.callback(Output('output', 'children'),
[Input('table', 'cols'),
Input('table', 'rows'),
Input('table', 'rowOrder'),
Input('table', 'colOrder'),
Input('table', 'aggregatorName'),
Input('table', 'rendererName'),
Input('table', 'vals')])
def display_props(cols, rows, row_order, col_order, aggregator, renderer, vals):
return [
html.P(str(cols), id='columns'),
html.P(str(rows), id='rows'),
html.P(str(row_order), id='row_order'),
html.P(str(col_order), id='col_order'),
html.P(str(aggregator), id='aggregator'),
html.P(str(renderer), id='renderer'),
html.P(str(vals), id='vals'),
]
if __name__ == '__main__':
app.run_server(debug=True)
Dash 1.19.0
Dash Core Components 1.1.2
Dash HTML Components 1.15.0
Dash Renderer 1.9.0
Dash Pivot Table 0.0.2
Is there a way to expose clickCallback to be able to do drilldowns? This is an added feature in react-pivottable. The javascript call for it looks like from the react demo is;
tableOptions: {
clickCallback: function(e, value, filters, pivotData) {
var names = [];
pivotData.forEachMatchingRecord(filters, function(
record
) {
names.push(record.Meal);
});
alert(names.join('\n'));
I want multiple pivot tables to be generated on the dash dashboard. The number of pivot tables is to be decided by the user input. Or is there a way to add a 'add pivot table' button and on each click a new pivot able is generated on the dashboard?
I am implementing the Dash Pivottable as part of a larger dashboard but would like to see the ability to define or change the default colors and overall styling.
Additionally, is the text that appears at the bottom of the of the pivot table essential? I would like this to be hidden if possible.
I apologize if this is the wrong forum for this type of request.
Is it possible to add rendererOptions in the input.
I am trying to build a pivot table with heatmap
where I want color coding for values in the table.
I just want conditional formatting of styling in table or heatmaps.
Hi @xhlulu, really glad you built this.
I've been trying to get your example working with an existing flask app. I tried to follow the plotly example for integrating a dash app with a flask app with the Werkzeug DispatcherMiddleware
(https://dash.plot.ly/integrating-dash). This is how i imported the dash app from usage.py:
from werkzeug.serving import run_simple
from flask_app.app import app as flask_app
from dash_pivottable.usage import app as dash_app
application = DispatcherMiddleware(
flask_app, {
'/dash': dash_app.server
}
)
if __name__ == '__main__':
run_simple('localhost', 8080, application)
Error: dash_pivottable was not found.
at Object.resolve (registry.js:17)
at q (TreeContainer.js:226)
at G (TreeContainer.js:263)
at TreeContainer.js:303
at connect.js:110
at i.updateMergedPropsIfNeeded (connect.js:224)
at i.render (connect.js:348)
at ce ([email protected]?v=1.0.0&m=1562232467:98)
at qg ([email protected]?v=1.0.0&m=1562232467:97)
at hi ([email protected]?v=1.0.0&m=1562232467:104)```
Let me know if you need more information!
hi ,
how to add a new renderer like violin plot or different types of plots which plotly supports .
Where I have to go and make the change ?
Thanks.
Hi.
I am integrating PivotTable with other components in the same screen. I have already included a scrollable DIV
as suggested in #7 but I would really like to be able to specify the size of the plots. Due to the nature of my data I get very large plots that would be much better if rendered in a smaller format.
The code would be something like this:
return html.Div(id='div_pivot', children=[
dash_pivottable.PivotTable(
id='Tabela',
data=data,
cols=dic_pivot['cols'],
#colOrder='key_a_to_z',
rows=dic_pivot['rows'],
#rowOrder='key_a_to_z',
rendererName='Table',
aggregatorName='Sum',
vals=dic_pivot['vals'],
valueFilter={},
hiddenFromAggregators=dic_pivot['hiddenFromAggregators'],
hiddenFromDragDrop=dic_pivot['vals'],
hiddenAttributes=hidden,
#The line below is a suggestion and causes an error in the current version
rendererOptions={'autosize':True, 'width':700, 'height':450,},
),], style={'height':'450px', 'overflow':'scroll', 'resize':'both'} )
How can I export figures as interactive HTML?
Adding a style command to set the width has no effect on graph or iframe.
Example:
#Pivot table test
html.Div(dash_pivottable.PivotTable(
id='table',
data=data,
cols=['Day of Week'],
colOrder="key_a_to_z",
rows=['Party Size'],
rowOrder="key_a_to_z",
rendererName="Table",
aggregatorName="Average",
vals=["Total Bill"],
valueFilter={'Day of Week': {'Thursday': False}},
),
style= {'width': 300};
),
# Row 4
Hi, it is really useful and interesting.
Wondering if can have it for Jupyter Dash?
Hi,
Thanks for the great library! I was wondering if it were possible to have scatter plots colored by group in dash-pivottable?
For instance, in this example i made in dash-pivottable, I plot two columns with aggregation = first(status). Ideally I would like to see the color legend as displayed in image 2 .If yes, how would I do this? Thanks.
This works:
import dash
import dash_html_components as html
from dash.dependencies import Input, Output
import dash_pivottable
app = dash.Dash(__name__)
app.layout = html.Div(
[html.Button("Rfresh", id="button"), html.Div(id="pivottable_div")]
)
@app.callback(Output("pivottable_div", "children"), [Input("button", "n_clicks")])
def refresh_pivottable(n_clicks):
if n_clicks:
print(n_clicks)
return [
html.Div(str(n_clicks)),
dash_pivottable.PivotTable(data=[["a"], [n_clicks]], cols=["a"])
if n_clicks % 2 == 1
else "a",
]
if __name__ == "__main__":
app.run_server(debug=False)
This doesn't:
import dash
import dash_html_components as html
from dash.dependencies import Input, Output
import dash_pivottable
app = dash.Dash(__name__)
app.layout = html.Div(
[html.Button("Rfresh", id="button"), html.Div(id="pivottable_div")]
)
@app.callback(Output("pivottable_div", "children"), [Input("button", "n_clicks")])
def refresh_pivottable(n_clicks):
if n_clicks:
print(n_clicks)
return [
html.Div(str(n_clicks)),
dash_pivottable.PivotTable(data=[["a"], [n_clicks]], cols=["a"])
# if n_clicks % 2 == 1
# else "a",
]
if __name__ == "__main__":
app.run_server(debug=False)
The only difference of them is the 2 commented lines.
My environment:
windows7 64bit
python3.7 64bit
dash 1.4.1
Please run the cases to see the difference. Many thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.