Changeset 2961 in products for quintagroup.analytics/trunk/quintagroup/analytics/browser/views.py
- Timestamp:
- Nov 2, 2010 12:08:40 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.analytics/trunk/quintagroup/analytics/browser/views.py
r2908 r2961 18 18 from GChartWrapper import VerticalBarStack 19 19 20 from quintagroup.analytics.config import COLORS, OTHER_TYPES 21 20 22 class OwnershipByType(BrowserView): 21 23 MAX = 10 … … 47 49 return self.users 48 50 49 def getTypes(self ):51 def getTypes(self, all=False): 50 52 if self.types is None: 51 53 index = self.cat._catalog.getIndex('portal_type') … … 62 64 data.sort(lambda a, b: a[1] - b[1]) 63 65 data.reverse() 64 self.types = [i[0] for i in data [:self.MAX]]65 return self.types66 self.types = [i[0] for i in data] 67 return all and self.types or self.types[:self.MAX] 66 68 67 69 def getContent(self, type_): … … 82 84 def getChart(self): 83 85 data = [] 84 for type_ in self.getTypes(): 86 types = self.getTypes() 87 for type_ in types: 85 88 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)]) 86 91 max_value = max(self.getTotal()) 87 92 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)) 89 94 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) 92 96 chart.size(800, 375).scale(0,max_value).axes('xy').label(*self.users) 93 97 chart.axes.type("y") … … 166 170 chart.title('Content ownership by state').legend(*self.states) 167 171 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) 170 173 chart.size(800, 375).scale(0,max_value).axes('xy').label(*self.users) 171 174 chart.axes.type("y") … … 245 248 chart.title('Content type by state').legend(*self.states) 246 249 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) 249 251 chart.size(800, 375).scale(0,max_value).axes('xy').label(*self.types) 250 252 chart.axes.type("y")
Note: See TracChangeset
for help on using the changeset viewer.