scatter_chart.py 1.5 KB

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