Skip to content

A django app to explore your data through charts based on Highcharts.js

License

Notifications You must be signed in to change notification settings

acdh-oeaw/acdh-django-charts

Repository files navigation

django_charts

https://travis-ci.org/acdh-oeaw/acdh-django-charts.svg?branch=master

An app to explore your data through charts based on Highcharts.js

Documentation

The full documentation is at https://acdh-django-charts.readthedocs.io.

Quickstart

Install django_charts:

pip install acdh-django-charts

Add it to your INSTALLED_APPS:

INSTALLED_APPS = (
    ...
    'charts',
    ...
)

Add django_charts's URL patterns:

urlpatterns = [
    ...
    url(r'^charts/', include('charts.urls', namespace='charts')),
    ...
]

By default the app's templates extend a base template webpage/base.html. To ovveride this, just define a CHARTS_BASE_TEMPLATE variable on your project's settings.py like e.g:

CHARTS_BASE_TEMPLATE = 'base.html'

To link to the application's 'chart-selector-view' you can add something like the snippet below to your e.g. base-template:

<a href="{% url 'charts:chart_selector' %}">Charts</a>

Configuration

To visualize any property of your model you have to pass in the models name (lowercase), the field-path (using django's lookup syntax __ to follow foreign key and many2many relations) and the chart type (bar|line|pie) via keyword arguments to the charts.views.DynChartView(). In case those params are valid (i.d. the model and the lookup path acutally exist) the according chart should be drawn. But be aware that this only works if your project's DEBUG settings are set to True. As recomended alternative you should create ChartConfig objects for each property/model you'd like to explore via django admin-backend.

management commands

The package ships with a management command to

  • create/delete chartconfig objects (Bar, Pie, Linecharts)
python manage.py create_charttypes
python manage.py delete_charttypes
  • create/delete ChartConfig objects per application
python manage.py create_charts <app_name>
python manage.py delete_charts <app_name>

Build and publish

python setup.py sdist bdist_wheel
twine upload dist/*

Features

  • Visualizes aggregated values of your models as charts (pie/bar/line) using https://www.highcharts.com/
  • Charts can be configured via admin backend (see Configuration Section)

Running Tests

Does the code actually work?

source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ tox

Credits

Tools used in rendering this package:

About

A django app to explore your data through charts based on Highcharts.js

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published