scatter.py 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #Autogenerated by ReportLab guiedit do not edit
  2. from reportlab.graphics.charts.legends import Legend
  3. from reportlab.graphics.charts.lineplots import ScatterPlot
  4. from reportlab.graphics.shapes import Drawing, _DrawingEditorMixin, String
  5. from reportlab.graphics.charts.textlabels import Label
  6. from reportlab.graphics.samples.excelcolors import *
  7. class Scatter(_DrawingEditorMixin,Drawing):
  8. def __init__(self,width=200,height=150,*args,**kw):
  9. Drawing.__init__(self,width,height,*args,**kw)
  10. self._add(self,ScatterPlot(),name='chart',validate=None,desc="The main chart")
  11. self.chart.width = 115
  12. self.chart.height = 80
  13. self.chart.x = 30
  14. self.chart.y = 40
  15. self.chart.lines[0].strokeColor = color01
  16. self.chart.lines[1].strokeColor = color02
  17. self.chart.lines[2].strokeColor = color03
  18. self.chart.lines[3].strokeColor = color04
  19. self.chart.lines[4].strokeColor = color05
  20. self.chart.lines[5].strokeColor = color06
  21. self.chart.lines[6].strokeColor = color07
  22. self.chart.lines[7].strokeColor = color08
  23. self.chart.lines[8].strokeColor = color09
  24. self.chart.lines[9].strokeColor = color10
  25. self.chart.fillColor = backgroundGrey
  26. self.chart.lineLabels.fontName = 'Helvetica'
  27. self.chart.xValueAxis.labels.fontName = 'Helvetica'
  28. self.chart.xValueAxis.labels.fontSize = 7
  29. self.chart.xValueAxis.forceZero = 0
  30. self.chart.data = [((100,100), (200,200), (250,210), (300,300), (400,500)), ((100,200), (200,300), (250,200), (300,400), (400, 600))]
  31. self.chart.xValueAxis.avoidBoundFrac = 1
  32. self.chart.xValueAxis.gridEnd = 115
  33. self.chart.xValueAxis.tickDown = 3
  34. self.chart.xValueAxis.visibleGrid = 1
  35. self.chart.yValueAxis.tickLeft = 3
  36. self.chart.yValueAxis.labels.fontName = 'Helvetica'
  37. self.chart.yValueAxis.labels.fontSize = 7
  38. self._add(self,Label(),name='Title',validate=None,desc="The title at the top of the chart")
  39. self.Title.fontName = 'Helvetica-Bold'
  40. self.Title.fontSize = 7
  41. self.Title.x = 100
  42. self.Title.y = 135
  43. self.Title._text = 'Chart Title'
  44. self.Title.maxWidth = 180
  45. self.Title.height = 20
  46. self.Title.textAnchor ='middle'
  47. self._add(self,Legend(),name='Legend',validate=None,desc="The legend or key for the chart")
  48. self.Legend.colorNamePairs = [(color01, 'Widgets'), (color02, 'Sprockets')]
  49. self.Legend.fontName = 'Helvetica'
  50. self.Legend.fontSize = 7
  51. self.Legend.x = 153
  52. self.Legend.y = 85
  53. self.Legend.dxTextSpace = 5
  54. self.Legend.dy = 5
  55. self.Legend.dx = 5
  56. self.Legend.deltay = 5
  57. self.Legend.alignment ='right'
  58. self.chart.lineLabelFormat = None
  59. self.chart.xLabel = 'X Axis'
  60. self.chart.y = 30
  61. self.chart.yLabel = 'Y Axis'
  62. self.chart.yValueAxis.labelTextFormat = '%d'
  63. self.chart.yValueAxis.forceZero = 1
  64. self.chart.xValueAxis.forceZero = 1
  65. self._add(self,0,name='preview',validate=None,desc=None)
  66. if __name__=="__main__": #NORUNTESTS
  67. Scatter().save(formats=['pdf'],outDir=None,fnRoot='scatter')