area_chart.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. Set,
  7. Bool,
  8. Integer,
  9. Sequence,
  10. Alias,
  11. )
  12. from openpyxl.descriptors.excel import ExtensionList
  13. from openpyxl.descriptors.nested import (
  14. NestedMinMax,
  15. NestedSet,
  16. NestedBool,
  17. )
  18. from ._chart import ChartBase
  19. from .descriptors import NestedGapAmount
  20. from .axis import TextAxis, NumericAxis, SeriesAxis, ChartLines
  21. from .label import DataLabelList
  22. from .series import Series
  23. class _AreaChartBase(ChartBase):
  24. grouping = NestedSet(values=(['percentStacked', 'standard', 'stacked']))
  25. varyColors = NestedBool(nested=True, allow_none=True)
  26. ser = Sequence(expected_type=Series, allow_none=True)
  27. dLbls = Typed(expected_type=DataLabelList, allow_none=True)
  28. dataLabels = Alias("dLbls")
  29. dropLines = Typed(expected_type=ChartLines, allow_none=True)
  30. _series_type = "area"
  31. __elements__ = ('grouping', 'varyColors', 'ser', 'dLbls', 'dropLines')
  32. def __init__(self,
  33. grouping="standard",
  34. varyColors=None,
  35. ser=(),
  36. dLbls=None,
  37. dropLines=None,
  38. ):
  39. self.grouping = grouping
  40. self.varyColors = varyColors
  41. self.ser = ser
  42. self.dLbls = dLbls
  43. self.dropLines = dropLines
  44. super(_AreaChartBase, self).__init__()
  45. class AreaChart(_AreaChartBase):
  46. tagname = "areaChart"
  47. grouping = _AreaChartBase.grouping
  48. varyColors = _AreaChartBase.varyColors
  49. ser = _AreaChartBase.ser
  50. dLbls = _AreaChartBase.dLbls
  51. dropLines = _AreaChartBase.dropLines
  52. # chart properties actually used by containing classes
  53. x_axis = Typed(expected_type=TextAxis)
  54. y_axis = Typed(expected_type=NumericAxis)
  55. extLst = Typed(expected_type=ExtensionList, allow_none=True)
  56. __elements__ = _AreaChartBase.__elements__ + ('axId',)
  57. def __init__(self,
  58. axId=None,
  59. extLst=None,
  60. **kw
  61. ):
  62. self.x_axis = TextAxis()
  63. self.y_axis = NumericAxis()
  64. super(AreaChart, self).__init__(**kw)
  65. class AreaChart3D(AreaChart):
  66. tagname = "area3DChart"
  67. grouping = _AreaChartBase.grouping
  68. varyColors = _AreaChartBase.varyColors
  69. ser = _AreaChartBase.ser
  70. dLbls = _AreaChartBase.dLbls
  71. dropLines = _AreaChartBase.dropLines
  72. gapDepth = NestedGapAmount()
  73. x_axis = Typed(expected_type=TextAxis)
  74. y_axis = Typed(expected_type=NumericAxis)
  75. z_axis = Typed(expected_type=SeriesAxis, allow_none=True)
  76. __elements__ = AreaChart.__elements__ + ('gapDepth', )
  77. def __init__(self, gapDepth=None, **kw):
  78. self.gapDepth = gapDepth
  79. super(AreaChart3D, self).__init__(**kw)
  80. self.x_axis = TextAxis()
  81. self.y_axis = NumericAxis()
  82. self.z_axis = SeriesAxis()