Skip to content

Commit

Permalink
add DashboardStats.x_axis_format chart configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
PetrDlouhy committed Jan 21, 2020
1 parent 4cedc6b commit 62df8b9
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
=========

0.13.0 (2020-01-16)
------------------
* add x_axis_format as DashboardStats field
* add interactive guideline to StackedAreaChart

0.12.0 (2020-01-16)
------------------

Expand Down
18 changes: 18 additions & 0 deletions admin_tools_stats/migrations/0004_dashboardstats_y_tick_format.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.9 on 2020-01-21 15:46

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('admin_tools_stats', '0003_auto_20191007_0950'),
]

operations = [
migrations.AddField(
model_name='dashboardstats',
name='y_axis_format',
field=models.CharField(blank=True, default=None, help_text="Format of Y axis. <a href='https://github.com/d3/d3-format'>See description of possible values</a>.", max_length=90, null=True, verbose_name='Y axis format'),
),
]
11 changes: 11 additions & 0 deletions admin_tools_stats/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,17 @@ class DashboardStats(models.Model):
choices=time_scales,
max_length=90,
)
y_axis_format = models.CharField(
max_length=90,
verbose_name=_("Y axis format"),
help_text=_(
"Format of Y axis."
"<a href='https://github.com/d3/d3-format' target='_blank'>See description of possible values</a>."
),
null=True,
blank=True,
default=None,
)
criteria = models.ManyToManyField(DashboardStatsCriteria, blank=True)
is_visible = models.BooleanField(default=True, verbose_name=_('visible'))
created_date = models.DateTimeField(auto_now_add=True, verbose_name=_('date'))
Expand Down
4 changes: 4 additions & 0 deletions admin_tools_stats/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ def get_context_data(self, *args, interval=None, graph_key=None, **kwargs):
'x_is_date': True,
'tag_script_js': False,
}

if dashboard_stats.y_axis_format:
context['extra']['y_axis_format'] = dashboard_stats.y_axis_format

if context['chart_type'] == 'stackedAreaChart':
context['extra']['use_interactive_guideline'] = True

Expand Down

0 comments on commit 62df8b9

Please sign in to comment.