Crosstab Customization


    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'),

        },

    ]

                

Live Example

Filters

Results

The reminder Code Name
8377 0 Product 0
7097 1 Product 1
7806 2 Product 2
8182 3 Product 3
7562 4 Product 4
8193 5 Product 5
8059 6 Product 6
8344 7 Product 7
8095 8 Product 8
8899 9 Product 9