Pivot Chart with DateTimeField from related model

This chart shows total sales based on when book was published. The data is limited to books published during June 1st-20th, 2010 for brevity.

Note that we filter down the possible values using date range queries instead of slicing. Slicing the query results in an error. Slicing in Chart() charts however is fine!

code

ds = PivotDataPool(
        series=[{
            'options': {
                'source': SalesHistory.objects.filter(
                            book__published_at__year=2010,
                            book__published_at__month=6,
                          ),
                'categories': 'book__published_at',
                'legend_by': 'book__title',
            },
            'terms': {
                'tot_sales': Sum('sale_qty'),
            }
        }]
)

pivcht = PivotChart(
    datasource=ds,
    series_options=[{
        'options': {
            'type': 'column',
            'stacking': True,
            'xAxis': 0,
            'yAxis': 0,
        },
        'terms': ['tot_sales']
    }]
)