Ticket #22: yvals_above_bars.patch
| File yvals_above_bars.patch, 1.3 kB (added by aprzywecki@…, 3 years ago) |
|---|
-
pycha/chart.py
653 653 shadow=True, 654 654 width=2 655 655 ), 656 showyvals=Option( 657 hide=True, 658 fontSize=11 659 ), 656 660 fillOpacity=1.0, 657 661 shouldFill=True, 658 662 barWidthFillFraction=0.75, -
pycha/bar.py
70 70 y = self.area.y + self.area.h * bar.y 71 71 w = self.area.w * bar.w 72 72 h = self.area.h * bar.h 73 74 # render yvals above bars 75 if not self.options.showyvals.hide: 76 cx.save() 77 cx.set_font_size(self.options.showyvals.fontSize) 78 cx.set_source_rgba(0, 0, 0, 1) 79 label = unicode(bar.yval) 80 extents = cx.text_extents(label) 81 labelWidth = extents[2] 82 labelHeight = extents[3] 83 cx.move_to(x+(w/2.0)-labelWidth, y-labelHeight) 84 cx.show_text(label) 85 cx.restore() 73 86 74 87 if w < 1 or h < 1: 75 88 return # don't draw when the bar is too small
