Line chart with DateField field

This chart plots sales quantities per day from the first book store.

Points to note:

  • sale_date is a DateField

code

ds = DataPool(
        series=[{
            'options': {
                'source': SalesHistory.objects.raw(
                            "SELECT * FROM demoproject_saleshistory "
                            "WHERE bookstore_id=%s LIMIT 10",
                            [BookStore.objects.first().pk]
                          )
            },
            'terms': [
                'sale_date',
                'sale_qty',
            ]
        }]
)

cht = Chart(
        datasource=ds,
        series_options=[{
            'options': {
                'type': 'line',
                'stacking': False
            },
            'terms': {
                'sale_date': [
                    'sale_qty',
                ]
            }
        }],
        chart_options={
            'title': {
                'text': 'Sales QTY per day'
            },
            'xAxis': {
                'title': {
                    'text': 'Sale date'
                }
            }
        }
)