Metadata-Version: 2.1
Name: polyviz
Version: 1.0.0
Summary: Interface between Brightway2 and D3.js
Home-page: https://github.com/romainsacchi/polyviz
Author: Romain Sacchi <romain.sacchi@psi.ch>
License: BSD 3-Clause License
        
        Copyright (c) 2020, Romain Sacchi
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        * Redistributions of source code must retain the above copyright notice, this
          list of conditions and the following disclaimer.
        
        * Redistributions in binary form must reproduce the above copyright notice,
          this list of conditions and the following disclaimer in the documentation
          and/or other materials provided with the distribution.
        
        * Neither the name of the copyright holder nor the names of its
          contributors may be used to endorse or promote products derived from
          this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        
Classifier: Intended Audience :: End Users/Desktop
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Topic :: Scientific/Engineering :: Visualization
Description-Content-Type: text/markdown
License-File: LICENSE

## ``polyviz``: An interface between ``brightway2`` and [D3.js](https://d3js.org/)

This is a Python package that provides an interface between the
[`brightway2`](https://brightway.dev) LCA framework and the [`D3.js`](https://d3js.org) JavaScript library.
It is designed to be used in Jupyter notebooks, and provides
interactive visualizations of LCA results.

<div align="center">
<img src="https://github.com/romainsacchi/polyviz/raw/main/assets/chord_sample.png" height="300"/>
</div>

This interface extends the capabilities of  [``d3blocks``](https://github.com/d3blocks/d3blocks), and make it compatible
with results generated by `brightway2`.

``polyviz`` allows the following visualizations to be created from LCA results:
* Sankey diagrams ([example 1](https://htmlpreview.github.io/?https://github.com/romainsacchi/polyviz/blob/main/examples/sankey_1.html), [example 2](https://htmlpreview.github.io/?https://github.com/romainsacchi/polyviz/blob/main/examples/sankey_2.html))
* Chord diagrams ([example 1](https://htmlpreview.github.io/?https://github.com/romainsacchi/polyviz/blob/main/examples/chord_1.html), [example 2](https://htmlpreview.github.io/?https://github.com/romainsacchi/polyviz/blob/main/examples/chord_2.html))
* Force-directed graphs ([example 1](https://htmlpreview.github.io/?https://github.com/romainsacchi/polyviz/blob/main/examples/force_1.html), [example 2](https://htmlpreview.github.io/?https://github.com/romainsacchi/polyviz/blob/main/examples/force_2.html))
* Tree maps ([example 1](https://htmlpreview.github.io/?https://github.com/romainsacchi/polyviz/blob/main/examples/treemap_1.html), [example 2](https://htmlpreview.github.io/?https://github.com/romainsacchi/polyviz/blob/main/examples/treemap_2.html))
* Choropleth maps ([example 1](https://htmlpreview.github.io/?https://github.com/romainsacchi/polyviz/blob/main/examples/choro_1.html), [example 2](https://htmlpreview.github.io/?https://github.com/romainsacchi/polyviz/blob/main/examples/choro_2.html))
* Violin plots ([example 1](https://htmlpreview.github.io/?https://github.com/romainsacchi/polyviz/blob/main/examples/violin_1.html), [example 2](https://htmlpreview.github.io/?https://github.com/romainsacchi/polyviz/blob/main/examples/violin_2.html))

## Limitations

Tested only with ``brightway2`` version 2.4.5.

Probably works with version 2.5 too, but not tested.

## Installation

Install ``polyviz`` from PyPI:

```bash
pip install polyviz
```

Usage
-----

### Sankey diagrams

```python
from polyviz import sankey
import bw2data

act = bw2data.get_activity(("some db", "some activity"))
method = ("some method", "some method")
sankey(activity=act, method=method)
```

`sankey()` returns a filepath to an HTML file that can be opened in a browser.

Alternatively, you can track a specific flow:

```python

from polyviz import sankey
import bw2data

act = bw2data.get_activity(("some db", "some activity"))
flow_type = "kilowatt hour"
sankey(activity=act, flow_type=flow_type)
```

Other examples are available in the [examples](https://github.com/romainsacchi/polyviz/blob/main/examples/examples.ipynb) notebook.

## Support

Do not hesitate to report issues in the Github repository.

## Maintainers

* [Romain Sacchi](https://github.com/romainsacchi)

## Contributing

See [contributing](https://github.com/romainsacchi/carculator/blob/master/CONTRIBUTING.md).

## License

[BSD-3-Clause](https://github.com/romainsacchi/polyviz/blob/master/LICENSE).
