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])
The results are seen in Fig. 727 and Fig. 728.
Fig. 727 Chart with data series color set to green
Fig. 728 Chart Area Color Dialog
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.
Fig. 729 Chart with data point color set to green
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])
The results are seen in Fig. 730 and Fig. 731.
Fig. 730 Chart with gradient data series modified
Fig. 731 Chart Data Series Area Gradient Dialog
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.
Fig. 732 Chart with gradient data point modified
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
Fig. 733 Chart with custom gradient data series formatting
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])
The results are seen in Fig. 734 and Fig. 735.
Fig. 734 Chart with data series background image
Fig. 735 Chart Data Series Area Image Dialog
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.
Fig. 736 Chart with data point background image
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])
The results are seen in Fig. 737 and Fig. 738.
Fig. 737 Chart data series with background pattern
Fig. 738 Chart Data Series Area Pattern Dialog
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.
Fig. 739 Chart data point with background pattern
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])
The results are seen in Fig. 740 and Fig. 741.
Fig. 740 Chart with data series background hatch
Fig. 741 Chart Data Series Area Hatch Dialog
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.
Fig. 742 Chart with data point background hatch