class TimeSeriesReport(ReportView):
report_title = _("Time Series Report")
report_description = _(
"Groups clients as rows and generates one column per month across the date range. The time_series_columns list defines what is computed for each period.")
report_model = SalesTransaction
group_by = "client"
date_field = "date"
# options are : "daily", "weekly", "bi-weekly", "monthly", "quarterly", "semiannually", "annually" and "custom"
time_series_pattern = "monthly"
# These columns will be calculated for each period in the time series.
time_series_columns = [
ComputationField.create(Sum, "value", verbose_name=_("Sales For ")),
]
columns = [
"name",
# placeholder for the generated time series columns
"__time_series__",
# This is the same as the time_series_columns, but this one will be on the whole set
ComputationField.create(Sum, "value", verbose_name=_("Total Sales")),
]
chart_settings = [
Chart(
"Client Sales",
Chart.BAR,
data_source=["sum__value"],
title_source=["name"],
),
Chart(
"Total Sales [Pie]",
Chart.PIE,
data_source=["sum__value"],
title_source=["name"],
plot_total=True,
),
Chart(
"Total Sales [Area chart]",
Chart.AREA,
data_source=["sum__value"],
title_source=["name"],
),
]