Metadata-Version: 2.2
Name: ckanext-fair3r-plotly
Version: 0.0.2.14
Summary: Plotly based charting for CKAN datastore data
Home-page: https://github.com/USEPA/ckanext-plotly
Author: Paul DeKraker
Author-email: dekraker.paul@epa.gov
License: AGPL
Keywords: CKAN
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
Classifier: Programming Language :: Python :: 2.7
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license
Dynamic: summary

![CKAN](https://img.shields.io/badge/CKAN-2.12.1-orange)
![Python](https://img.shields.io/badge/python-3.12-blue)
[![PyPI](https://img.shields.io/pypi/v/ckanext-fair3r-plotly)](https://pypi.org/project/ckanext-fair3r-plotly/)
![License](https://img.shields.io/badge/license-AGPL--3.0-blue)

# ckanext-plotly

Interactive **charts** of a tabular resource, right on its CKAN page,
built with [plotly.js](https://plotly.com/javascript/) and Plotly's
[react-chart-editor](https://github.com/plotly/react-chart-editor): pick
columns and a chart type, style it, zoom and hover - no code, no export.

Two resource views, for any resource loaded into the DataStore (by
xloader or datapusher):

| View | Plugin | What it does |
|---|---|---|
| **Chart Explorer** | `plotly_explorer` | Visitors build their own chart from the data, on the fly |
| **Chart** | `plotly` | An editor saves a chart with the view; visitors see that chart |

> Fork of [USEPA/ckanext-plotly](https://github.com/USEPA/ckanext-plotly),
> maintained by [Phen-ICS](https://github.com/Phen-ICS) (CNRS/IGBMC) for
> the [FAIR3R](https://fair3r.fr) catalogue. Published on PyPI as
> **`ckanext-fair3r-plotly`**; the plugins keep their names.

## What this fork changes

- **CKAN 2.11 and 2.12**: assets declared with WebAssets
  (`webassets.yml`, shipped in the package).
- Packaged for PyPI, with CI that tests, builds and publishes on every
  merge.

## Requirements

- CKAN 2.12 with the **DataStore** and a loader for it (xloader or
  datapusher): the views only offer themselves for resources whose data
  is in the DataStore.

## Installation

1. Install the package in CKAN's virtualenv (it has no dependencies of
   its own):

   ```shell
   pip install ckanext-fair3r-plotly
   ```

2. Enable one or both views in `ckan.ini`; optionally add them to the
   views created automatically for new resources:

   ```ini
   ckan.plugins = ... datastore xloader plotly_explorer
   ckan.views.default_views = ... plotly_explorer
   ```

3. Restart CKAN. On a resource loaded in the DataStore, **Manage ->
   Views -> New view** now offers "Chart Explorer" and/or "Chart".

No setting to configure.

## Rebuilding the chart editor

The editor is a React app (`editor_app/`) built once and shipped as
static files. To change it:

1. Build it:

   ```shell
   cd editor_app/src
   npm run build
   ```

2. Copy the bundles into the plugin:

   ```shell
   cp ../build/static/css/main*.css     ../../ckanext/plotly/public/plotly_edit_app.css
   cp ../build/static/css/main*.css.map ../../ckanext/plotly/public/plotly_edit_app.css.map
   cp ../build/static/js/main*.js       ../../ckanext/plotly/public/plotly_edit_app.js
   cp ../build/static/js/main*.js.map   ../../ckanext/plotly/public/plotly_edit_app.js.map
   ```

3. Point the last line of `plotly_edit_app.css` and `plotly_edit_app.js`
   (their source map reference) at the copied `.map` files.

## Tests

```shell
docker exec -u ckan -it ckan-app pytest --ckan-ini=/plugins/ckanext-plotly/test.ini /plugins/ckanext-plotly/ckanext
```

Always pass `--ckan-ini`: the fixtures empty the database they run
against, and refuse to run unless its name contains `test`.

## Credits and license

Originally written by the United States Environmental Protection Agency
([USEPA/ckanext-plotly](https://github.com/USEPA/ckanext-plotly)).
Released under the GNU Affero General Public License v3.0 - see
[`LICENSE`](https://github.com/Phen-ICS/ckanext-plotly/blob/master/LICENSE).

### Disclaimer (from the original project)

The United States Environmental Protection Agency (EPA) GitHub project
code is provided on an "as is" basis and the user assumes responsibility
for its use. EPA has relinquished control of the information and no
longer has responsibility to protect the integrity, confidentiality, or
availability of the information. Any reference to specific commercial
products, processes, or services by service mark, trademark,
manufacturer, or otherwise, does not constitute or imply their
endorsement, recommendation or favoring by EPA. The EPA seal and logo
shall not be used in any manner to imply endorsement of any commercial
product or activity by EPA or the United States Government.
