SimonBiggs / scriptedforms

Quickly create live-update GUIs for Python packages using Markdown and simple HTML elements.
Apache License 2.0
509 stars 34 forks source link

Create a Pivot Table js jupyterlab rendermime extension, make a way for JupyterLab rendermime extensions to be included within scriptedforms #105

Closed robmarkcole closed 6 years ago

robmarkcole commented 6 years ago

Thought I would create an issue to track ideas.

1 See if theres anything useful to learn from https://github.com/tryexceptpass/sofi

2 I see woking with csv/tables in the browser to be a big draw to scriptedforms. Pivot tables being the common operation perhaps the following is worth a look https://github.com/nicolaskruchten/jupyter_pivottablejs and video on http://nicolas.kruchten.com/content/2015/09/jupyter_pivottablejs/

SimonBiggs commented 6 years ago

wrt the pivot tables, pandas is the package underpinning the table variable.

Pandas already has the following: https://pandas.pydata.org/pandas-docs/stable/generated/pandas.pivot_table.html

Maybe it's worth creating an example that has a few drop downs to achieve an interactive pivot table.

When a pandas variable changes the table redraws to agree.

robmarkcole commented 6 years ago

pivottablejs is very interactive, you can drag the pivots around, and do a wide range of plots. I definitely recommend taking a couple of minutes to try it out. I will experiment and post my results

SimonBiggs commented 6 years ago

Actually, once again, I'll just leave that as it will be implemented within jupyterlab. The pandas variables will be able to be used as an interactive pivot table within jupyterlab soon I'm sure.

If ever one of your ideas has a solution where someone has made a notebook extension I'll leave that idea because it will likely be solved by default once I make scriptedforms into a jupyterlab extension.

Also, specifically, my preference for ideas are those that you will be specifically using. The highest priority ideas will come by trying to take your needs at work and turn them into forms and finding out there is functionality missing on being able to create what you want.

robmarkcole commented 6 years ago

OK sure, theres bound to be an explosion of extensions.

This suggestion came about as I've been asked to deal with a bunch of monstrous excel files and do pivots, and I'm sure scriptedforms can be a much nicer solution

SimonBiggs commented 6 years ago

Also, there's no harm in making each idea into an issue. That way each idea can be discussed individually.

SimonBiggs commented 6 years ago

Ahah :) thanks.

SimonBiggs commented 6 years ago

What would it look like?

robmarkcole commented 6 years ago

Try out https://github.com/robmarkcole/Useful-python/blob/master/Pandas/Pivot%2028-2-2018.ipynb

image

image

SimonBiggs commented 6 years ago

This lets you upload your CSV files to do it within the browser:

https://react-pivottable.js.org

Seeing that makes me think for that use case a standalone jupyterlab extension would be perfect.

robmarkcole commented 6 years ago

Yes your'e right, no need to reimplement in scriptedforms.

Will create separate issues for other ideas

SimonBiggs commented 6 years ago

...here's an idea... And if it works then maybe the pivot table will be more plausible:

https://handsontable.com

Swap out the table element for the above...

SimonBiggs commented 6 years ago

https://github.com/handsontable/angular-handsontable/blob/master/README.md

robmarkcole commented 6 years ago

@SimonBiggs I feel like pivot tables are a special case of table - typically I need to view them but not manipulate the data content. https://github.com/nicolaskruchten/jupyter_pivottablejs makes manipulation very easy, otherwise I have to manually add all the drop down menus etc around a standard table. Can we reopen this issue until we have a solution we are completely satisfied with?

SimonBiggs commented 6 years ago

Sure, how about we work out a way where you can include your own javascript? So instead of me including pivottablesjs, how about I just make a way for you to import that package in yourself?

robmarkcole commented 6 years ago

Sounds good. I've virtually no javascript experience but could be a good excuse to learn

SimonBiggs commented 6 years ago

@robmarkcole try the most recent development code submitted to master. There is a file in the example module called testing-pivot-table.md take that for a spin and let me know how you go.

SimonBiggs commented 6 years ago

@robmarkcole so, I worked around what the notebook pivot tables extension was expecting and I managed to include it in. But it is exceptionally brittle, because I have to mimic the state of the notebook javascript environment and file server handling. ... It worked, but it got in the way of what I am trying to do at the moment (get jupyterhub and mybinder to work). So I have now got rid of it again.

However! :) It shouldn't be too difficult to turn the pivottablejs into a JupyterLab extension. If you can turn it into a jupyterlab extension I can pull it in through the official channels.

A jupyterlab extension tutorial is provided at:

https://jupyterlab.readthedocs.io/en/stable/developer/xkcd_extension_tutorial.html

robmarkcole commented 6 years ago

@SimonBiggs thanks for your efforts on this. I will look at creating the JupyterLab extension. Indeed I'm hopefully attending a Hackathon @manahl in a couple of weeks and this would be a perfect task for the event

SimonBiggs commented 6 years ago

Ahh awesome :)

robmarkcole commented 6 years ago

@SimonBiggs are nbextensions also supported? Just learning about these but this is useful http://jupyter-contrib-nbextensions.readthedocs.io/en/latest/nbextensions/varInspector/README.html

SimonBiggs commented 6 years ago

No, they aren't unfortunately. Nbextensions are the old extension method. Need to use JupyterLab extension methods...

SimonBiggs commented 6 years ago

You'll be wanting this:

https://github.com/jupyterlab/mimerender-cookiecutter-ts

And this:

http://jupyterlab.readthedocs.io/en/stable/developer/extension_dev.html#mime-renderer-extensions

SimonBiggs commented 6 years ago

Here's an example:

https://github.com/jupyterlab/jupyterlab/tree/master/packages/vega2-extension

SimonBiggs commented 6 years ago

Hi @robmarkcole,

I'm going to close this issue. I'll let you work on a JupyterLab extension for a pivottable in another repo. Once the extension is made we can open a new issue then I think.