scatter_chart.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. Sequence,
  7. Alias
  8. )
  9. from openpyxl.descriptors.excel import ExtensionList
  10. from openpyxl.descriptors.nested import (
  11. NestedNoneSet,
  12. NestedBool,
  13. )
  14. from ._chart import ChartBase
  15. from .axis import NumericAxis
  16. from .series import XYSeries
  17. from .label import DataLabelList
  18. class ScatterChart(ChartBase):
  19. tagname = "scatterChart"
  20. scatterStyle = NestedNoneSet(values=(['line', 'lineMarker', 'marker', 'smooth', 'smoothMarker']))
  21. varyColors = NestedBool(allow_none=True)
  22. ser = Sequence(expected_type=XYSeries, allow_none=True)
  23. dLbls = Typed(expected_type=DataLabelList, allow_none=True)
  24. dataLabels = Alias("dLbls")
  25. extLst = Typed(expected_type=ExtensionList, allow_none=True)
  26. x_axis = Typed(expected_type=NumericAxis)
  27. y_axis = Typed(expected_type=NumericAxis)
  28. _series_type = "scatter"
  29. __elements__ = ('scatterStyle', 'varyColors', 'ser', 'dLbls', 'axId',)
  30. def __init__(self,
  31. scatterStyle=None,
  32. varyColors=None,
  33. ser=(),
  34. dLbls=None,
  35. extLst=None,
  36. **kw
  37. ):
  38. self.scatterStyle = scatterStyle
  39. self.varyColors = varyColors
  40. self.ser = ser
  41. self.dLbls = dLbls
  42. self.x_axis = NumericAxis(axId=10, crossAx=20)
  43. self.y_axis = NumericAxis(axId=20, crossAx=10)
  44. super(ScatterChart, self).__init__(**kw)