[reportlab-users] horizontalbarcharts with negative data

Nicholas Wieland nicholas_wieland at yahoo.it
Thu Aug 11 06:11:10 EDT 2005


I'm trying to have an horizontalbarchart with positive/negative data, but for some reason reportlab raises a TypeError
 
Traceback (innermost last):
  Module ZPublisher.Publish, line 101, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 39, in call_object
  Module Products.InstitutionalReport.InstitutionalReport, line 69, in generate
  Module Products.InstitutionalReport.Reporter, line 185, in generate
  Module reportlab.platypus.doctemplate, line 644, in build
  Module reportlab.platypus.doctemplate, line 562, in handle_flowable
  Module reportlab.platypus.frames, line 139, in _add
  Module reportlab.platypus.flowables, line 97, in drawOn
  Module reportlab.platypus.flowables, line 82, in _drawOn
  Module reportlab.graphics.shapes, line 599, in draw
  Module reportlab.graphics.renderbase, line 189, in draw
  Module reportlab.graphics.renderPDF, line 51, in drawNode
  Module reportlab.graphics.renderbase, line 245, in drawNodeDispatcher
  Module reportlab.graphics.renderbase, line 262, in drawGroup
  Module reportlab.graphics.renderbase, line 162, in _expandUserNode
  Module reportlab.graphics.widgetbase, line 151, in provideNode
  Module reportlab.graphics.charts.barcharts, line 457, in draw
  Module reportlab.graphics.charts.barcharts, line 168, in _drawFinish
  Module reportlab.graphics.charts.axes, line 209, in configure
TypeError: len() of unsized object

This is the code:
 
class Bar (_DrawingEditorMixin, Drawing):
 
    def __init__(self, data, width = 120, height = 50, *args, **kwds):
      apply (Drawing.__init__, (self, width, height) + args, kwds)
      self._add (self, HorizontalBarChart (), name = 'chart', validate = None, desc = None)
      self.chart.width = 200
      self.chart.height = 90
      self.chart.x = 350
      self.chart.y = 5
      self.chart.valueAxis.valueMin = -0.4
      self.chart.valueAxis.valueMax = +0.4
      self.chart.categoryAxis.categoryNames = data ['cnames']
      self.chart.data = data ['delta']
      self._add (self, 0, name = 'preview', validate = None, desc = None)

class Bar (_DrawingEditorMixin, Drawing):
    def __init__(self, data, width = 120, height = 50, *args, **kwds):
      apply (Drawing.__init__, (self, width, height) + args, kwds)
      self._add (self, HorizontalBarChart (), name = 'chart', validate = None, desc = None)
      self.chart.width = 200
      self.chart.height = 90
      self.chart.x = 350
      self.chart.y = 5
      self.chart.valueAxis.valueMin = -0.4
      self.chart.valueAxis.valueMax = +0.4
      self.chart.categoryAxis.categoryNames = data ['cnames']
      self.chart.data = data ['delta']
      self._add (self, 0, name = 'preview', validate = None, desc = None)

 
data is:
 
{'delta': [0.010199999999999987, -0.009000000000000008, -0.0011999999999999789],
 'cnames': ['Azionario', 'Hedge', 'Liquidit\xc3\xa0 e Obbligazionario']}
 
 
and I call it:
 
report_story.append (Bar (data = assetClass (IReportObj, ptf_code, reference_date, type = "dchart")))
 
 
What's the problem here ?
Numbers are too small ?
 
TIA,
  ngw

		
---------------------------------
Yahoo! Mail: gratis 1GB per i messaggi, antispam, antivirus, POP3
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://two.pairlist.net/pipermail/reportlab-users/attachments/20050811/bcad07db/attachment.html


More information about the reportlab-users mailing list