def df(n, dp=2, ds='.', ts=','): try: _df = _DF[dp, ds] except KeyError: _df = _DF[dp, ds] = DecimalFormatter(places=dp, decimalSep=ds, thousandSep=ts) return _df(n)
def applyPrec(P, prec): if prec is None: return P R = [].append f = DecimalFormatter(places=prec) for p in P: if isSeq(p): n = [].append for e in p: if isinstance(e, float): e = float(f(e)) n(e) p = n.__self__ R(p) return R.__self__
def draw_bar_plot(self, data, names): d = Drawing(50, 100) bar = HorizontalBarChart() bar.data = data bar.x = 180 bar.y = 0 bar.categoryAxis.categoryNames = names bar.valueAxis.valueMin = 0 bar.valueAxis.valueMax = 100 bar.bars[0].fillColor = self.rgb_to_color_obj((65, 182, 230)) bar.barLabels.angle = 0 bar.barLabelFormat = DecimalFormatter(2, suffix='%') bar.barLabels.dx = 20 d.add(bar, '') self.content.append(self.small_space) self.content.append(d) self.content.append(self.large_space)
def __init__(self, xList, yList, width=400, height=200, *args, **kw): Drawing.__init__(self, width, height, *args, **kw) self.width = 80 * 1.2 * 2.5 self.height = 60 * 0.8 * 2.5 self._add(self, HorizontalBarChart(), name='chart', validate=None, desc=None) self.chart.y = 11.2 * 2 self.chart.x = 20 * 2 #self.chart.data = [[0.05, 0.05, 0.1, 0.1, 0.05, 0.05, 0.955555]] self.chart.data = yList self.chart.width = self.width * 0.75 self.chart.height = self.height * 0.75 self.chart.bars.strokeColor = None self.chart.bars[0].fillColor = colors.blue self.chart.valueAxis.valueMin = 0 self.chart.valueAxis.valueMax = 1.0 self.chart.valueAxis.valueStep = 0.2 self.chart.categoryAxis.visibleTicks = False self.chart.barLabelFormat = DecimalFormatter(3) self.chart.barLabels.boxAnchor = 'w' self.chart.barLabels.fontSize = 2.8 * 2.5 self.chart.barLabels.fontName = 'Helvetica-Bold' self.chart.valueAxis.labels.fontSize = 2.8 * 2.5 self.chart.valueAxis.labels.fontName = 'Helvetica-Bold' #self.chart.categoryAxis.categoryNames = ['unaligned', 'mRNA', 'rRNA', 'snoRNA', 'tRNA', 'hairpin miRNA', 'miRNA'] self.chart.categoryAxis.categoryNames = xList self.chart.categoryAxis.labels.fontSize = 2.8 * 2.5 self.chart.categoryAxis.labels.fontName = 'Helvetica-Bold' self._add(self, Label(), name='XLabel', validate=None, desc='Percentage') self.XLabel.fontSize = 4.4 * 2 self.XLabel.fontName = 'Helvetica-Bold' self.XLabel._text = 'Percentage' self.XLabel.dx = 48 * 2.5 self.XLabel.dy = 2
def GraficoCustoVariavel(self): grafico = Drawing(200, 200) dados = [ (self.CustoCombHora, self.CustoOleoHora, self.CustoManutencaoHoraTrator, self.PrecoTratorista), ] barras = VerticalBarChart() barras.x = 0 barras.y = 0 barras.height = 150 barras.width = 150 barras.data = dados barras.barLabelFormat = DecimalFormatter(2) barras.barLabels.nudge = 6 barras.categoryAxis.categoryNames = [ 'Combustível', 'Óleo', 'Manutenção', 'Operador' ] barras.categoryAxis.labels.angle = 45 barras.categoryAxis.labels.boxAnchor = 'ne' grafico.add(barras) return grafico
def GraficoCustoFixoImplemento(self): grafico = Drawing(200, 200) dados = [ (self.DepreciacaoImplemento, self.JuroImplemento, self.GaragemImplemento, self.SeguroImplemento), ] barras = VerticalBarChart() barras.x = 0 barras.y = 0 barras.height = 150 barras.width = 150 barras.data = dados barras.barLabelFormat = DecimalFormatter(2) barras.barLabels.nudge = 6 barras.categoryAxis.categoryNames = [ 'Depreciação', 'Juros', 'Garagem', 'Seguro' ] barras.categoryAxis.labels.angle = 45 barras.categoryAxis.labels.boxAnchor = 'ne' grafico.add(barras) return grafico
lp.xValueAxis.tickDown = 10 lp.xValueAxis.visibleAxis = True lp.xValueAxis.valueSteps = None lp.xValueAxis.visibleGrid = True lp.xValueAxis.xLabelFormat = '{mm},{dd},{yyyy}' # y axis lp.yValueAxis.avoidBoundFrac = 0.1 lp.yValueAxis.drawGridLast = True lp.yValueAxis.forceZero = True lp.yValueAxis.gridStrokeWidth = 0.5 lp.yValueAxis.labels.dy = 0 lp.yValueAxis.labels.fontName = 'Times-Roman' lp.yValueAxis.labels.fontSize = 10 lp.yValueAxis.labels.rightPadding = 10 lp.yValueAxis.labelTextFormat = DecimalFormatter(places=0, thousandSep=',', decimalSep='.', prefix='$') lp.yValueAxis.maximumTicks = 7 lp.yValueAxis.rangeRound = 'floor' lp.yValueAxis.strokeWidth = 0.5 lp.yValueAxis.tickLeft = 5 lp.yValueAxis.tickRight = 0 lp.yValueAxis.valueMax = None lp.yValueAxis.valueMin = None lp.yValueAxis.valueStep = None lp.yValueAxis.visibleAxis = True lp.yValueAxis.visibleGrid = True lp.yValueAxis.visibleTicks = True lp.data = [[(19960901, 100000.0), (19961201, 109034.00000000001), (19970301, 110105.00000000001), (19970601, 127487.0), (19970901, 134702.0), (19971201, 136920.0), (19980301, 153788.0),