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


in django view have:

females = demographic.objects.filter(gender__startswith='f') males = demographic.objects.filter(gender__startswith='m') 

i use chartit have graph number of people per sex, in other words show females.count() , males.count().

do have idea how customize data chartit pivot chart?

currently code 1 below not working.

ds = pivotdatapool(     series=[         {'options': {             'source':demographic.objects.filter(gender__startswith='f'),             'categories':['gender'] },             'terms':{                 'sex_count':females.count(),                 }         }     ] )  pvcht = pivotchart(     datasource=ds,     series_options =           [{'options':{             'type': 'column',             'stacking': true},             'terms':[             'sex_count']}],      chart_options =           {'title': {                'text': 'total number'},            'xaxis': {                 'title': {                    'text': 'sex'}}} ) 

i found 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'}}} ) 

Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -