radar.py 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #Autogenerated by ReportLab guiedit do not edit
  2. from reportlab.graphics.charts.legends import Legend
  3. from reportlab.graphics.samples.excelcolors import *
  4. from reportlab.graphics.charts.spider import SpiderChart
  5. from reportlab.graphics.shapes import Drawing, _DrawingEditorMixin, String
  6. from reportlab.graphics.charts.textlabels import Label
  7. class RadarChart(_DrawingEditorMixin,Drawing):
  8. def __init__(self,width=200,height=150,*args,**kw):
  9. Drawing.__init__(self,width,height,*args,**kw)
  10. self._add(self,SpiderChart(),name='chart',validate=None,desc="The main chart")
  11. self.chart.width = 90
  12. self.chart.height = 90
  13. self.chart.x = 45
  14. self.chart.y = 25
  15. self.chart.strands[0].strokeColor= color01
  16. self.chart.strands[1].strokeColor= color02
  17. self.chart.strands[2].strokeColor= color03
  18. self.chart.strands[3].strokeColor= color04
  19. self.chart.strands[4].strokeColor= color05
  20. self.chart.strands[5].strokeColor= color06
  21. self.chart.strands[6].strokeColor= color07
  22. self.chart.strands[7].strokeColor= color08
  23. self.chart.strands[8].strokeColor= color09
  24. self.chart.strands[9].strokeColor= color10
  25. self.chart.strands[0].fillColor = None
  26. self.chart.strands[1].fillColor = None
  27. self.chart.strands[2].fillColor = None
  28. self.chart.strands[3].fillColor = None
  29. self.chart.strands[4].fillColor = None
  30. self.chart.strands[5].fillColor = None
  31. self.chart.strands[6].fillColor = None
  32. self.chart.strands[7].fillColor = None
  33. self.chart.strands[8].fillColor = None
  34. self.chart.strands[9].fillColor = None
  35. self.chart.strands.strokeWidth = 1
  36. self.chart.strandLabels.fontName = 'Helvetica'
  37. self.chart.strandLabels.fontSize = 6
  38. self.chart.fillColor = backgroundGrey
  39. self.chart.data = [(125, 180, 200), (100, 150, 180)]
  40. self.chart.labels = ['North', 'South', 'Central']
  41. self._add(self,Label(),name='Title',validate=None,desc="The title at the top of the chart")
  42. self.Title.fontName = 'Helvetica-Bold'
  43. self.Title.fontSize = 7
  44. self.Title.x = 100
  45. self.Title.y = 135
  46. self.Title._text = 'Chart Title'
  47. self.Title.maxWidth = 180
  48. self.Title.height = 20
  49. self.Title.textAnchor ='middle'
  50. self._add(self,Legend(),name='Legend',validate=None,desc="The legend or key for the chart")
  51. self.Legend.colorNamePairs = [(color01, 'Widgets'), (color02, 'Sprockets')]
  52. self.Legend.fontName = 'Helvetica'
  53. self.Legend.fontSize = 7
  54. self.Legend.x = 153
  55. self.Legend.y = 85
  56. self.Legend.dxTextSpace = 5
  57. self.Legend.dy = 5
  58. self.Legend.dx = 5
  59. self.Legend.deltay = 5
  60. self.Legend.alignment ='right'
  61. self.chart.strands.strokeWidth = 1
  62. self._add(self,0,name='preview',validate=None,desc=None)
  63. if __name__=="__main__": #NORUNTESTS
  64. RadarChart().save(formats=['pdf'],outDir=None,fnRoot='radar')