Let's add some charts and customizations
``__crosstab__`` special column name
and
``crosstab_compute_reminder`` controlling if compute reminder is an option or no.
and
``plot_total`` chart setting works on Crosstab too.
*please choose Client(s) and check the results.*
class CrosstabCustomization(SlickReportView):
report_model = SalesLineTransaction
report_title = _('Product Client sales Cross-tab')
date_field = 'transaction_date'
group_by = 'product'
columns = ['__crosstab__', # a special column name to control the placing fot eh crosstab columns inside th results
'slug', 'name']
crosstab_model = 'client'
crosstab_columns = [SlickReportField.create(Sum, 'value', name='value__sum', verbose_name=_('Sales'))]
crosstab_compute_reminder = True # if False the "Reminder" Column will not be computed
chart_settings = [
{
'type': 'pie',
'data_source': ['value__sum'],
'plot_total': True, # Plot total works here too
'title_source': ['name'],
'title': _('Per Client Total %'),
},
{
'type': 'bar',
'data_source': ['value__sum'],
'title_source': ['name'],
'title': _('Per Client Per Product'),
},
{
'type': 'bar',
'data_source': ['value__sum'],
'plot_total': True,
'title_source': ['name'],
'stacking': 'normal',
'title': _('Per Client Total'),
},
]