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
8204 0 Product 0
8946 1 Product 1
8546 2 Product 2
8888 3 Product 3
8495 4 Product 4
8493 5 Product 5
8065 6 Product 6
8711 7 Product 7
7575 8 Product 8
8339 9 Product 9