[Answer]-Django: how to customize my data in pivot chart of chartit module

1👍

I found the solution using django aggregate function. See below:

ds = PivotDataPool(
    series=[
        {'options': {
            'source':Demographic.objects.all(),
            'categories':['gender'] },
            'terms':{
                'sex_count':Count('gender'),
                }
        }
    ]
)

pvcht = PivotChart(
    datasource=ds,
    series_options =
          [{'options':{
            'type': 'column',
            #'stacking': True
            },
            'terms':[
            'sex_count']}],
     chart_options =
          {'title': {
               'text': 'Total number'},
           'xAxis': {
                'title': {
                   'text': 'Sex'}}}
)
👤zinon

Leave a comment