Skip to content

Commit

Permalink
decouple url and outfile_path
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaskruchten committed May 8, 2017
1 parent 06c3966 commit 7e5e3cc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions README.rst
Expand Up @@ -24,18 +24,18 @@ Usage
Advanced Usage
--------------

Include any `valid option`_ to PivotTable.js's `pivotUI()` function as a keyword argument.
Include any `option to PivotTable.js's pivotUI() function`_ as a keyword argument.

.. code:: python
pivot_ui(df, rows=['row_name'], cols=['col_name'])
Independently control the output file path and the URL used to access it from Jupyter.
Independently control the output file path and the URL used to access it from Jupyter, in case the default relative-URL behaviour is incompatible with Jupyter's settings.

.. code:: python
pivot_ui(df, outfile_path="x.html", url_prefix="http://localhost/path/")
pivot_ui(df, outfile_path="/x/y.html", url="http://localhost/a/b/x.html")
.. _Jupyter/IPython Notebook: http://jupyter.org/
.. _PivotTable.js: https://github.com/nicolaskruchten/pivottable
.. _valid option: https://github.com/nicolaskruchten/pivottable/wiki/Parameters#options-object-for-pivotui
.. _valid option to PivotTable.js's pivotUI() function: https://github.com/nicolaskruchten/pivottable/wiki/Parameters#options-object-for-pivotui
4 changes: 2 additions & 2 deletions pivottablejs/__init__.py
Expand Up @@ -68,10 +68,10 @@
from IPython.display import IFrame
import json

def pivot_ui(df, outfile_path = "pivottablejs.html", url_prefix="",
def pivot_ui(df, outfile_path = "pivottablejs.html", url="",
width="100%", height="500", **kwargs):
with open(outfile_path, 'w') as outfile:
outfile.write(TEMPLATE %
dict(csv=df.to_csv(), kwargs=json.dumps(kwargs)))
return IFrame(src=url_prefix+outfile_path, width=width, height=height)
return IFrame(src=url or outfile_path, width=width, height=height)

2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -22,7 +22,7 @@
# Versions should comply with PEP440. For a discussion on single-sourcing
# the version across setup.py and the project code, see
# https://packaging.python.org/en/latest/single_source_version.html
version='0.4.0',
version='0.5.0',

description='PivotTable.js integration for Jupyter/IPython Notebook',
long_description=long_description,
Expand Down

0 comments on commit 7e5e3cc

Please sign in to comment.