0

mysqlデータデータベースから表示するデータを収集しながら、pdfやその他の形式でグラフを表示するこの簡単なコードを書いています。コードはエラーなしで実行されていますが、ファイルは生成されていません。助けてください。

from rlextra.graphics.guiedit.datacharts import DataAwareDrawing, DataSource, ODBCDataSource, DataAssociation

from reportlab.graphics.shapes import _DrawingEditorMixin

from reportlab.graphics.charts.lineplots import GridLinePlot

class Ok(_DrawingEditorMixin,DataAwareDrawing):

                def __init__(self,width=800,height=800,*args,**kw):
                                DataAwareDrawing.__init__(self,width,height,*args,**kw)
                                self._add(self,GridLinePlot(),name='plot',validate=None,desc=None)
                                self.height           = 125
                                self.width            = 300
                                self.plot.height          =125
                                self.plot.width           = 300
                                self.plot.x               = 50
                                self.plot.y               = 50
                                self.dataSource       = ODBCDataSource()
                                self.dataSource.driver                   = 'mysql'
                                self.dataSource.user                     = 'root'
                                self.dataSource.password                 = 'soumya'
                                self.dataSource.name                     = 'fundrep'
                                self.dataSource.sql                      = 'SELECT fund_id, periodEnd, fundReturn,indexReturn FROM fundrep_monthlyreturnseriess ORDER BY fund_id, periodEnd'
                                self.outDir           = 'output'
                                self.fileNamePattern  = 'pleaserun'
                                self.formats          = ['pdf', 'eps', 'gif']
                                self.dataSource.associations.size       = 2
                                self.dataSource.associations.element00  = DataAssociation(column=0, target='chartId', assocType='scalar')
                                self.dataSource.associations.element01  = DataAssociation(column=[(1,2),(1,3)], target='plot.data', assocType='tmatrix')

if __name__=="__main__": #NORUNTESTS

                 Ok().go()
4

1 に答える 1

1

これがすべてのコードであると仮定すると、この問題は、ファイルに書き出すために ReportLab Canvas に実際に描画することがないことにあるようです。ReportLab の一般的な動作は次のとおりです。

  1. ドキュメントを描画するためのキャンバスを作成します。
  2. ドキュメントを描画します (つまり、ページを作成したり、ページに要素を配置したりします)。
  3. ドキュメントをファイルに書き出します。

あなたのコードではそのようなことは起こらないので、ReportLab は何も出力しないと思います。

于 2011-06-07T14:22:21.037 に答える