Skip to main content

Super-simple self-contained interactive HTML-Reports combining elements from various sources. Manages styling and layout via customisable css.

Project description

divfusion

divfusion takes multiple HTML elements and generates a stand-alone HTML-Report while managing styling and layout. In practise, these elements ('divs') would originate from other Python modules, especially those that generate plots and provide a html export (e.g. plotly).

If used with plotly, this closes between a single-figure plotly export and a full-fledged plotly-dash server, which needs to be hosted somewhere. Using this Library, all interactivity of plotly is preserved (hovering, zooming, buttons, dropdowns, etc.). In addition to that, you can add html-exports of your pd.DataFrames, images or any other HTML content. divfusion brings all of this together and manges the layout and style of the report for you (bring your own css is possible in a future version).

The resulting html file is completely self-contained and can be opened in any browser on any device.

Installation

You can install divfusion via pip:

pip install divfusion

Usage

To use divfusion.Report, you must first import the class:

from divfusion import Report

Next, create a new instance of Report by passing the following parameters:

  • title - The title of the report (string)
  • div_like - A list of div_like elements. Can be
    • strings
    • plotly figures
    • pandas dataframes
    • pandas series
    • All nested combinations of the above (first dimension is columns, second dimension is rows)
  • css_files (optional) - The CSS files to include (list)
  • js_files (optional) - The JS files to include (list)
  • js_libs (optional) - A list of JS libraries to include (list)
report = Report(title="My Report",
                div_like=[[px.scatter(x=[1, 2, 3], y=[1, 2, 3]), "<div>some text</div>"],
                          ["<div>Some Info Text</div>", "<div>HTML Table</div>"],
                          [pd.DataFrame([[1, 2, 3], [4, 5, 6]]), pd.Series([1, 2, 3])]
                          ])

The Elements will be placed as the nested list of divs suggests: Columns horizontally, Rows vertically. Optionally you can add custom css files, js files or js script tags.

To generate the HTML report, call the write method and pass the file path where you want to save the report:

report.write("path/to/report.html")

Dependencies

Currently divfusion requires pandas>=1.4.0 and plotly>=5.0.0. Python >= 3.10 is required.

Future Work

  • Add support for custom css
  • Provide easy-to-use wrapper functions for adding plotly-figures, pandas-dataframes, etc.

Contribution

I welcome any and all contributions, no matter what size. Please feel free to open an issue or pull request against dev.

License

Apache License 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

divfusion-0.3.4.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

divfusion-0.3.4-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file divfusion-0.3.4.tar.gz.

File metadata

  • Download URL: divfusion-0.3.4.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for divfusion-0.3.4.tar.gz
Algorithm Hash digest
SHA256 d70cdbf29892c655dd4dc3c9b9dd4dd5726d49ae21560a531ef8202ad1898f5a
MD5 d7ad08d83b65c6a9c3568f92c4db8838
BLAKE2b-256 6a0176668cb4ce05dd9a198b64615176a3ff17d413ef43609ec439f63943b8d3

See more details on using hashes here.

File details

Details for the file divfusion-0.3.4-py3-none-any.whl.

File metadata

  • Download URL: divfusion-0.3.4-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for divfusion-0.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 5faf2ca6bf6ac6f2844b3d5ba5790d71e925753f239a4f02d7bb07f4d9e6f70a
MD5 58904d71581d7584b278292299eb29ac
BLAKE2b-256 c59af3ad992cdc7daf2098a45af4d99c1db9473e8b8bd7320711a5f1127d7dfb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page