Chart2 Direct series Data Series Area (Static)
Overview
The ooodev.format.chart2.direct.series.data_series.area
module contains classes that are used to set the data series area of a Chart.
Calls to the Chart2.style_data_series()
and Chart2.style_data_point()
methods are used to set the data series area of a Chart.
Setup
General setup for examples.
import uno
from ooodev.format.chart2.direct.series.data_series.area import Color as DataSeriesColor
from ooodev.format.chart2.direct.general.borders import LineProperties as ChartLineProperties
from ooodev.format.chart2.direct.general.area import Gradient as ChartGradient, PresetGradientKind
from ooodev.office.calc import Calc
from ooodev.office.chart2 import Chart2
from ooodev.utils.color import StandardColor
from ooodev.gui import GUI
from ooodev.loader.lo import Lo
def main() -> int:
with Lo.Loader(connector=Lo.ConnectPipe()):
doc = Calc.open_doc("col_chart.ods")
GUI.set_visible(True, doc)
Lo.delay(500)
Calc.zoom(doc, GUI.ZoomEnum.ZOOM_100_PERCENT)
sheet = Calc.get_active_sheet()
Calc.goto_cell(cell_name="A1", doc=doc)
chart_doc = Chart2.get_chart_doc(sheet=sheet, chart_name="col_chart")
chart_bdr_line = ChartLineProperties(color=StandardColor.BLUE_LIGHT3, width=0.7)
chart_grad = ChartGradient.from_preset(chart_doc, PresetGradientKind.TEAL_BLUE)
Chart2.style_background(chart_doc=chart_doc, styles=[chart_grad, chart_bdr_line])
data_series_color = DataSeriesColor(StandardColor.TEAL_DARK2)
Chart2.style_data_series(chart_doc=chart_doc, styles=[data_series_color])
Lo.delay(1_000)
Lo.close_doc(doc)
return 0
if __name__ == "__main__":
SystemExit(main())
Color
The ooodev.format.chart2.direct.series.data_series.area.Color
class is used to set the background color of a data series in Chart.
Before formatting the chart is seen in Fig. 829.
Apply the background color to a data series
Style Data Series
from ooodev.format.chart2.direct.series.data_series.area import Color as DataSeriesColor
# ... other code
data_series_color = DataSeriesColor(StandardColor.TEAL_DARK2)
Chart2.style_data_series(chart_doc=chart_doc, styles=[data_series_color])
Style Data Point
# ... other code
Chart2.style_data_point(chart_doc=chart_doc, series_idx=0, idx=2, styles=[data_series_color])
The results are seen in Fig. 729.
Gradient
The ooodev.format.chart2.direct.series.data_series.area.Gradient
class is used to set the background gradient of a Chart.
Before formatting the chart is seen in Fig. 829.
Gradient from preset
Apply the preset gradient to a data series
The PresetGradientKind
enum is used to select the preset gradient.
Style Data Series
from ooodev.format.chart2.direct.series.data_series.area import Gradient as DataSeriesGradient
# ... other code
data_series_grad = DataSeriesGradient.from_preset(chart_doc, PresetGradientKind.DEEP_OCEAN)
Chart2.style_data_series(chart_doc=chart_doc, styles=[data_series_grad])
Style Data Point
# ... other code
Chart2.style_data_point(chart_doc=chart_doc, series_idx=0, idx=-1, styles=[data_series_grad])
The results are seen in Fig. 732.
Apply a custom Gradient
Demonstrates how to create a custom gradient.
Apply the preset gradient to a data series
from ooodev.format.chart2.direct.series.data_series.area import Gradient as DataSeriesGradient
from ooodev.format.chart2.direct.series.data_series.area import GradientStyle, ColorRange
# ... other code
data_series_grad = DataSeriesGradient(
chart_doc=chart_doc,
style=GradientStyle.LINEAR,
angle=215,
grad_color=ColorRange(StandardColor.TEAL_DARK3, StandardColor.BLUE_LIGHT2),
)
Chart2.style_data_series(chart_doc=chart_doc, styles=[data_series_grad])
The results are seen in Fig. 733
Image
The ooodev.format.chart2.direct.series.data_series.area.Img
class is used to set the data series background image of a Chart.
Before formatting the chart is seen in Fig. 829.
Apply background image of a Chart
The PresetImageKind
enum is used to select an image preset.
Style Data Series
from ooodev.format.chart2.direct.series.data_series.area import Img as SeriesImg
from ooodev.format.chart2.direct.series.data_series.area import PresetImageKind
# ... other code
data_series_img = SeriesImg.from_preset(chart_doc, PresetImageKind.POOL)
Chart2.style_data_series(chart_doc=chart_doc, styles=[data_series_img])
Style Data Point
# ... other code
Chart2.style_data_point(chart_doc=chart_doc, series_idx=0, idx=0, styles=[data_series_img])
The results are seen in Fig. 736.
Pattern
The ooodev.format.chart2.direct.series.data_series.area.Pattern
class is used to set the background pattern of a Chart.
Before formatting the chart is seen in Fig. 829.
Apply background pattern of a Chart
The PresetPatternKind
enum is used to select a pattern preset.
Style Data Series
from ooodev.format.chart2.direct.series.data_series.area import Pattern as SeriesPattern
from ooodev.format.chart2.direct.series.data_series.area import PresetPatternKind
# ... other code
data_series_pattern = SeriesPattern.from_preset(chart_doc, PresetPatternKind.ZIG_ZAG)
Chart2.style_data_series(chart_doc=chart_doc, styles=[data_series_pattern])
Style Data Point
# ... other code
Chart2.style_data_point(chart_doc=chart_doc, series_idx=0, idx=4, styles=[data_series_pattern])
The results are seen in Fig. 739.
Hatch
The ooodev.format.chart2.direct.series.data_series.area.Hatch
class is used to set the background hatch of a Chart.
Before formatting the chart is seen in Fig. 829.
Apply background hatch of a Chart
The PresetHatchKind
enum is used to select a hatch preset.
Style Data Series
from ooodev.format.chart2.direct.series.data_series.area import Hatch as SeriesHatch
from ooodev.format.chart2.direct.series.data_series.area import PresetHatchKind
# ... other code
data_series_hatch = SeriesHatch.from_preset(chart_doc, PresetHatchKind.BLUE_45_DEGREES_CROSSED)
Chart2.style_data_series(chart_doc=chart_doc, styles=[data_series_hatch])
Style Data Point
# ... other code
Chart2.style_data_point(chart_doc=chart_doc, series_idx=0, idx=-1, styles=[data_series_hatch])
The results are seen in Fig. 742.