-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
211 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
Time Series Reports | ||
================== | ||
|
||
|
||
Here is a quick recipe to what you want to do | ||
|
||
.. code-block:: python | ||
from django.utils.translation import gettext_lazy as _ | ||
from django.db.models import Sum | ||
from slick_reporting.views import SlickReportView | ||
class MyReport(SlickReportView): | ||
time_series_pattern = "monthly" | ||
# options are : "daily", "weekly", "monthly", "yearly", "custom" | ||
# if time_series_pattern is "custom", then you can specify the dates like so | ||
# time_series_custom_dates = [ | ||
# (datetime.date(2020, 1, 1), datetime.date(2020, 1, 14)), | ||
# (datetime.date(2020, 2, 1), datetime.date(2020, 2, 14)), | ||
# (datetime.date(2020, 3, 1), datetime.date(2020, 3,14)), | ||
] | ||
time_series_columns = [ | ||
SlickReportField.create(Sum, "value", verbose_name=_("Value")), | ||
] | ||
# These columns will be calculated for each period in the time series. | ||
columns = ['some_optional_field', | ||
'__time_series__', | ||
# You can customize where the time series columns are displayed in relation to the other columns | ||
SlickReportField.create(Sum, "value", verbose_name=_("Value")), | ||
# This is the same as the time_series_columns, but this one will be on the whole set | ||
] | ||
time_series_selector = True | ||
# This will display a selector to change the time series pattern | ||
# settings for the time series selector | ||
# ---------------------------------- | ||
time_series_selector_choices=None # A list Choice tuple [(value, label), ...] | ||
time_series_selector_default = "monthly" # The initial value for the time series selector | ||
time_series_selector_label = _("Period Pattern) # The label for the time series selector | ||
time_series_selector_allow_empty = False # Allow the user to select an empty time series | ||
Links to demo | ||
------------- | ||
Time series Selector pattern Demo `Demo <https://my-shop.django-erp-framework.com/reports/profitability/profitabilityreportmonthly/>`_ | ||
and here is the `Code on github <https://github.com/RamezIssac/my-shop/blob/main/general_reports/reports.py#L44>`_ for the report. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
|
||
Report View Options | ||
=================== | ||
|
||
We can categorize the output of a report into 4 sections: | ||
|
||
* List report: Similar to a django changelist, it's a direct view of the report model records with some extra features like sorting, filtering, pagination, etc. | ||
* Grouped report: similar to what you'd expect from a SQL group by query, it's a list of records grouped by a certain field | ||
* Time series report: a step up from the grouped report, where the results are computed for each time period (day, week, month, year, etc) or you can specify a custom periods. | ||
* Crosstab report: It's a report where a table showing the relationship between two or more variables. (like Client sales of each product comparison) | ||
|
||
|
||
|
||
General Options | ||
--------------- | ||
|
||
* columns | ||
|
||
Columns can be a list of column names , or a tuple of (column name, options dictionary) pairs. | ||
|
||
example: | ||
|
||
.. code-block:: python | ||
class MyReport() | ||
columns = [ | ||
'id', | ||
('name', {'verbose_name': "My verbose name", is_summable=False}), | ||
'description', | ||
] | ||
* date_field: the date field to be used in filtering and computing (ie: the time series report). | ||
* report_model: the model where the relevant data is stored, in more complex reports, it's usually a database view / materialized view. | ||
|
||
* report_title: the title of the report to be displayed in the report page. | ||
|
||
* group_by : the group by field, if not specified, the report will be a list report. | ||
|
||
* excluded_fields | ||
|
||
* chart_settings : a list of dictionary (or Chart object) of charts you want to attach to the report. | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
default_app_config = "slick_reporting.apps.ReportAppConfig" | ||
|
||
VERSION = (0, 7, 0) | ||
VERSION = (0, 8, 0) | ||
|
||
__version__ = "0.7.0" | ||
__version__ = "0.8.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.