surface_chart.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. from __future__ import absolute_import
  2. # Copyright (c) 2010-2019 openpyxl
  3. from openpyxl.descriptors.serialisable import Serialisable
  4. from openpyxl.descriptors import (
  5. Typed,
  6. Integer,
  7. Bool,
  8. Alias,
  9. Sequence,
  10. )
  11. from openpyxl.descriptors.excel import ExtensionList
  12. from openpyxl.descriptors.nested import (
  13. NestedInteger,
  14. NestedBool,
  15. )
  16. from ._chart import ChartBase
  17. from ._3d import _3DBase
  18. from .axis import TextAxis, NumericAxis, SeriesAxis
  19. from .shapes import GraphicalProperties
  20. from .series import Series
  21. class BandFormat(Serialisable):
  22. tagname = "bandFmt"
  23. idx = NestedInteger()
  24. spPr = Typed(expected_type=GraphicalProperties, allow_none=True)
  25. graphicalProperties = Alias("spPr")
  26. __elements__ = ('idx', 'spPr')
  27. def __init__(self,
  28. idx=0,
  29. spPr=None,
  30. ):
  31. self.idx = idx
  32. self.spPr = spPr
  33. class BandFormatList(Serialisable):
  34. tagname = "bandFmts"
  35. bandFmt = Sequence(expected_type=BandFormat, allow_none=True)
  36. __elements__ = ('bandFmt',)
  37. def __init__(self,
  38. bandFmt=(),
  39. ):
  40. self.bandFmt = bandFmt
  41. class _SurfaceChartBase(ChartBase):
  42. wireframe = NestedBool(allow_none=True)
  43. ser = Sequence(expected_type=Series, allow_none=True)
  44. bandFmts = Typed(expected_type=BandFormatList, allow_none=True)
  45. _series_type = "surface"
  46. __elements__ = ('wireframe', 'ser', 'bandFmts')
  47. def __init__(self,
  48. wireframe=None,
  49. ser=(),
  50. bandFmts=None,
  51. **kw
  52. ):
  53. self.wireframe = wireframe
  54. self.ser = ser
  55. self.bandFmts = bandFmts
  56. super(_SurfaceChartBase, self).__init__(**kw)
  57. class SurfaceChart3D(_SurfaceChartBase, _3DBase):
  58. tagname = "surface3DChart"
  59. wireframe = _SurfaceChartBase.wireframe
  60. ser = _SurfaceChartBase.ser
  61. bandFmts = _SurfaceChartBase.bandFmts
  62. extLst = Typed(expected_type=ExtensionList, allow_none=True)
  63. x_axis = Typed(expected_type=TextAxis)
  64. y_axis = Typed(expected_type=NumericAxis)
  65. z_axis = Typed(expected_type=SeriesAxis)
  66. __elements__ = _SurfaceChartBase.__elements__ + ('axId',)
  67. def __init__(self, **kw):
  68. self.x_axis = TextAxis()
  69. self.y_axis = NumericAxis()
  70. self.z_axis = SeriesAxis()
  71. super(SurfaceChart3D, self).__init__(**kw)
  72. class SurfaceChart(SurfaceChart3D):
  73. tagname = "surfaceChart"
  74. wireframe = _SurfaceChartBase.wireframe
  75. ser = _SurfaceChartBase.ser
  76. bandFmts = _SurfaceChartBase.bandFmts
  77. extLst = Typed(expected_type=ExtensionList, allow_none=True)
  78. __elements__ = SurfaceChart3D.__elements__
  79. def __init__(self, **kw):
  80. super(SurfaceChart, self).__init__(**kw)
  81. self.y_axis.delete = True
  82. self.view3D.x_rotation = 90
  83. self.view3D.y_rotation = 0
  84. self.view3D.perspective = False
  85. self.view3D.right_angle_axes = False