src/reportlab/graphics/charts/barcharts.py
changeset 3385 e45ca0b2053c
parent 3382 20385a50ac8d
child 3397 4f1ca0e6b818
equal deleted inserted replaced
3384:4c9c0dcf0995 3385:e45ca0b2053c
    64         reversePlotOrder = AttrMapValue(isBoolean, desc='If true, reverse common category plot order.',advancedUsage=1),
    64         reversePlotOrder = AttrMapValue(isBoolean, desc='If true, reverse common category plot order.',advancedUsage=1),
    65         naLabel = AttrMapValue(NoneOrInstanceOfNA_Label, desc='Label to use for N/A values.',advancedUsage=1),
    65         naLabel = AttrMapValue(NoneOrInstanceOfNA_Label, desc='Label to use for N/A values.',advancedUsage=1),
    66         annotations = AttrMapValue(None, desc='list of callables, will be called with self, xscale, yscale.'),
    66         annotations = AttrMapValue(None, desc='list of callables, will be called with self, xscale, yscale.'),
    67         categoryLabelBarSize = AttrMapValue(isNumber, desc='width to leave for a category label to go between categories.'),
    67         categoryLabelBarSize = AttrMapValue(isNumber, desc='width to leave for a category label to go between categories.'),
    68         categoryLabelBarOrder = AttrMapValue(OneOf('first','last','auto'), desc='where any label bar should appear first/last'),
    68         categoryLabelBarOrder = AttrMapValue(OneOf('first','last','auto'), desc='where any label bar should appear first/last'),
       
    69         barRecord = AttrMapValue(None, desc='callable(bar,label=labelText,value=value,**kwds) to record bar information', advancedUsage=1),
    69         )
    70         )
    70 
    71 
    71     def makeSwatchSample(self, rowNo, x, y, width, height):
    72     def makeSwatchSample(self, rowNo, x, y, width, height):
    72         baseStyle = self.bars
    73         baseStyle = self.bars
    73         styleIdx = rowNo % len(baseStyle)
    74         styleIdx = rowNo % len(baseStyle)
   467         g.add(r)
   468         g.add(r)
   468 
   469 
   469     def _makeBars(self,g,lg):
   470     def _makeBars(self,g,lg):
   470         lenData = len(self.data)
   471         lenData = len(self.data)
   471         bars = self.bars
   472         bars = self.bars
       
   473         br = getattr(self,'barRecord',None)
   472         for rowNo in range(lenData):
   474         for rowNo in range(lenData):
   473             row = self._barPositions[rowNo]
   475             row = self._barPositions[rowNo]
   474             styleCount = len(bars)
   476             styleCount = len(bars)
   475             styleIdx = rowNo % styleCount
   477             styleIdx = rowNo % styleCount
   476             rowStyle = bars[styleIdx]
   478             rowStyle = bars[styleIdx]
   496                     symbol.width = width
   498                     symbol.width = width
   497                     symbol.height = height
   499                     symbol.height = height
   498                     g.add(symbol)
   500                     g.add(symbol)
   499                 elif abs(width)>1e-7 and abs(height)>=1e-7 and (style.fillColor is not None or style.strokeColor is not None):
   501                 elif abs(width)>1e-7 and abs(height)>=1e-7 and (style.fillColor is not None or style.strokeColor is not None):
   500                     self._makeBar(g,x,y,width,height,rowNo,style)
   502                     self._makeBar(g,x,y,width,height,rowNo,style)
       
   503                     if br: br(g.contents[-1],label=self._getLabelText(rowNo,colNo),value=self.data[rowNo][colNo],rowNo=rowNo,colNo=colNo)
   501 
   504 
   502                 self._addBarLabel(lg,rowNo,colNo,x,y,width,height)
   505                 self._addBarLabel(lg,rowNo,colNo,x,y,width,height)
   503 
   506 
   504     def makeBars(self):
   507     def makeBars(self):
   505         g = Group()
   508         g = Group()