Ignore:
Timestamp:
Nov 2, 2010 12:08:40 PM (14 years ago)
Author:
fenix
Message:

extend ownership by type view:added other types into chart; all content types are listed in table now

File:
1 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.analytics/trunk/quintagroup/analytics/browser/views.py

    r2908 r2961  
    1818from GChartWrapper import VerticalBarStack 
    1919 
     20from quintagroup.analytics.config import COLORS, OTHER_TYPES 
     21 
    2022class OwnershipByType(BrowserView): 
    2123    MAX = 10 
     
    4749        return self.users 
    4850 
    49     def getTypes(self): 
     51    def getTypes(self, all=False): 
    5052        if self.types is None: 
    5153            index = self.cat._catalog.getIndex('portal_type') 
     
    6264            data.sort(lambda a, b: a[1] - b[1]) 
    6365            data.reverse() 
    64             self.types = [i[0] for i in data[:self.MAX]] 
    65         return self.types 
     66            self.types = [i[0] for i in data] 
     67        return all and self.types or self.types[:self.MAX] 
    6668 
    6769    def getContent(self, type_): 
     
    8284    def getChart(self): 
    8385        data = [] 
    84         for type_ in self.getTypes(): 
     86        types = self.getTypes() 
     87        for type_ in types: 
    8588            data.append(self.getContent(type_)) 
     89        other = [self.getContent(t) for t in self.getTypes(all=True)[self.MAX:]] 
     90        data.append([sum(l) for l in zip(*other)]) 
    8691        max_value = max(self.getTotal()) 
    8792        chart = VerticalBarStack(data, encoding='text') 
    88         chart.title('Content ownership by type').legend(*self.types) 
     93        chart.title('Content ownership by type').legend(*(types+OTHER_TYPES)) 
    8994        chart.bar('a', 10, 0).legend_pos("b") 
    90         chart.color('669933', 'CC9966', '993300', 'FF6633', 'E8E4E3', 'A9A486', 
    91                     'DCB57E', 'FFCC99', '996633', '333300') 
     95        chart.color(*COLORS) 
    9296        chart.size(800, 375).scale(0,max_value).axes('xy').label(*self.users) 
    9397        chart.axes.type("y") 
     
    166170        chart.title('Content ownership by state').legend(*self.states) 
    167171        chart.bar('a', 10, 0).legend_pos("b") 
    168         chart.color('669933', 'CC9966', '993300', 'FF6633', 'E8E4E3', 'A9A486', 
    169                     'DCB57E', 'FFCC99', '996633', '333300') 
     172        chart.color(*COLORS) 
    170173        chart.size(800, 375).scale(0,max_value).axes('xy').label(*self.users) 
    171174        chart.axes.type("y") 
     
    245248        chart.title('Content type by state').legend(*self.states) 
    246249        chart.bar('a', 10, 0).legend_pos("b") 
    247         chart.color('669933', 'CC9966', '993300', 'FF6633', 'E8E4E3', 'A9A486', 
    248                     'DCB57E', 'FFCC99', '996633', '333300') 
     250        chart.color(*COLORS) 
    249251        chart.size(800, 375).scale(0,max_value).axes('xy').label(*self.types) 
    250252        chart.axes.type("y") 
Note: See TracChangeset for help on using the changeset viewer.