nicolaskruchten / pivottable

Open-source Javascript Pivot Table (aka Pivot Grid, Pivot Chart, Cross-Tab) implementation with drag'n'drop.
https://pivottable.js.org/
MIT License
4.35k stars 1.08k forks source link

pivotable.js with Visual Studio Code #1269

Open Edge4711 opened 3 years ago

Edge4711 commented 3 years ago

Hi there, this looks like a great data exploration addition. I looked through the documentation but was unable to find any information about the possibility of using pivottablejs within a notebook in Visual Studio Code I have tried this example without success

import pandas as pd from pivottablejs import pivot_ui from IPython.display import HTML

df = pd.read_csv('datafile') pivot_ui(df, outfile_path='pivottablejs.html') HTML('pivottablejs.html')

It executes fine ... but no output

miraks31 commented 3 years ago

Does anyone have an answer or a possible workaround to avoid pivottable.js blocking ?

luukburger commented 2 years ago

I'm also running into this. The output .html file works perfectly when opened in a browser, but with the code as above it won't render anything in VS Code.

VS Code: 1.71.2 Jupyter: v2022.8.1002431955 Jupyter Notebook renderers: v1.0.9

marcusze commented 1 year ago

Same problem with vs code here. Any solutions or ideas to fix this?

canutog commented 1 year ago

Hi, I did not find a workaround to use pivottable on vscode. But, if you open the pivottablejs.html that is generated into your folder in a web browser, you're able to use it normally.

Also you can install jupyterlab and type jupyter notebook on terminal to start a jupyter server from vscode and use this library also from the web browser.

dave-killough commented 1 year ago

I've had success using pivottablejs in various notebook environments like Google Colab by assigning the iframe's srcdoc with the HTML/JS instead of serving the file. You will use full-screen mode, but it's more likely to work where serving a file is problematic. Encoding quotes is important.

Nicolas: srcdoc would be a nice alternative in your Jupyter pivot. Cloud notebooks don't serve local files like Jupyter on your computer.

srcdoc = TEMPLATE.replace('__CSV__',csv)
srcdoc = srcdoc.replace('"','"')  # encode quotes
display(HTML(('''
  <iframe
      width="100%"
      height="500"
      srcdoc="''' + srcdoc + '''"
      frameborder="0"
      allowfullscreen
  ></iframe>
''')))

On Tue, Jun 13, 2023 at 12:32 PM canutera @.***> wrote:

Hi, I did not find a workaround to use pivottable on vscode. But, if you open the pivottablejs.html that is generated into your folder, you're able to use it normally.

Also you can install jupyterlab and type jupyter notebook on terminal to start a jupyter server from vscode and use this library also from the web browser.

— Reply to this email directly, view it on GitHub https://github.com/nicolaskruchten/pivottable/issues/1269#issuecomment-1589654878, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF47UKQDTTFX57ZYQUWBQ4DXLCI3TANCNFSM4Z5OMWMQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>