Compare matrices in a django app
Project description
Chart Compare
This is meant to be a distributed package for use in allowing chart and graphical comparisons from numerically based django models.
Detailed documentation is in the "docs" directory.
Quick start
Imports
from django_chart_compare import Utils
or:
from django_chart_compare import Compare
Uses
For comparing base data from multiple parent models, you can use the compare module.
Implementation example:
views.py:
from django_chart_compare import Compare
from django.views import generic
from .models import Schedule
...
class ComparisonGraphs(generic.TemplateView):
model = Schedule # your matrix model
template_name = 'app/multi.html'
context_object_name = 'chart'
def get_context_data(self, **kwargs):
context = super(ComparisonGraphs, self).get_context_data(**kwargs)
comp = Compare(Schedule, self.request, **kwargs)
script, div = comp.lane_comp_plotter()
context['html'] = comp.df.to_html()
context['col_dict'] = comp.col_dict
context['name_dict'] = comp.name_dict
context['script'] = script
context['div'] = div
context['schedule'] = Schedule.objects.get(pk=self.kwargs['pk'])
return context
urls.py: The view above needs self.get_context_data() to receive kwargs of pk and slug, where pk is the id of the primary model and the slug is a string with dashes ("-") separating the id's of the comparison models.
url_patterns = [
...
url(r'^schedule/(?P<pk>[0-9_]+)/compare/(?P<slug>[0-9]+(-[0-9]+)*)/more-reports/$',
views.ComparisonGraphs.as_view(), name='more-reports'),
# or if using path in django 2
path('test/<int:pk>/<slug:slug>/', ComparisonGraphs.as_view(), name='test'),
]
And in app/multi.html:
<form action="" method="GET" class="form-horizontal">
<!-- iterate through column values to list all possible selections for comparison -->
{% for pk, sched_columns in col_dict.items %}
<div class="ColumnLists" >
{{ name_dict|get_item:pk }} <br>
<select class="ColumnLists" size="{{ sched_columns|length }}" name="{{ pk }}">
{% for key, col in sched_columns.items %}
<option value="{{ key }}" >
<td>{{ col }}</td>
</option>
{% endfor %}
</select>
</div>
{% endfor %}
</form>
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
Built Distribution
Close
Hashes for django-chart-compare-1.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a12c57e5fd9167bd0c95371d760e485d4d85d367293c3ff2a16bec58fb2d6ba |
|
MD5 | 877c501ed6a22a98ec7e0641717d23ff |
|
BLAKE2b-256 | ca0d016a7cbdcda58ec33f0d899fe739e303bc70b18eafd7d41d033b08b2a815 |
Close
Hashes for django_chart_compare-1.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ca55dfce45918bc6e3b2f2cb4fdfc720558fe67b21d9eb3ee005f48b90fbb12 |
|
MD5 | cd576e33c265e6f7f0459a636df189ab |
|
BLAKE2b-256 | 4e1befa3e5a0a7f02f90a1edc75410658d62dd1f9d591836f48fea8175eb8d91 |