Chart2 Direct Wall/Floor Area
Overview
The various style_*
methods are used to format the wall/floor of a Chart.
Setup
General setup for examples.
from __future__ import annotations
from pathlib import Path
import uno
from ooodev.calc import CalcDoc, ZoomKind
from ooodev.loader.lo import Lo
from ooodev.utils.color import StandardColor
def main() -> int:
with Lo.Loader(connector=Lo.ConnectPipe()):
fnm = Path.cwd() / "tmp" / "col_chart3d.ods"
doc = CalcDoc.open_doc(fnm=fnm, visible=True)
Lo.delay(500)
doc.zoom(ZoomKind.ZOOM_100_PERCENT)
sheet = doc.sheets[0]
sheet["A1"].goto()
chart_table = sheet.charts[0]
chart_doc = chart_table.chart_doc
_ = chart_doc.style_border_line(
color=StandardColor.PURPLE_DARK1,
width=0.7,
)
wall = chart_doc.first_diagram.wall
wall.style_area_color(StandardColor.DEFAULT_BLUE)
Lo.delay(1_000)
doc.close()
return 0
if __name__ == "__main__":
SystemExit(main())
Color
The style_area_color()
method is used to set the background color the chart wall and floor.
Before applying formatting is seen in Fig. 830.
Apply the background color to a wall and floor
Apply to wall.
from ooodev.utils.color import StandardColor
# ... other code
wall = chart_doc.first_diagram.wall
wall.style_area_color(StandardColor.DEFAULT_BLUE)
Apply to floor.
from ooodev.utils.color import StandardColor
# ... other code
floor = chart_doc.first_diagram.floor
floor.style_area_color(StandardColor.DEFAULT_BLUE)
The results are seen in Fig. 530 and Fig. 531
Fig. 530 Chart with Wall and Floor color set
Fig. 531 Chart Wall Color Dialog
Gradient
The style_area_gradient_from_preset()
method is called to set the background gradient of a Chart Wall/Floor.
Before applying formatting is seen in Fig. 830.
Gradient from preset
Apply the preset gradient to wall and floor
The PresetGradientKind
enum is used to select the preset gradient.
Apply to wall.
from ooodev.format.inner.preset.preset_gradient import PresetGradientKind
# ... other code
wall = chart_doc.first_diagram.wall
wall.style_area_gradient_from_preset(
preset=PresetGradientKind.DEEP_OCEAN,
)
Apply to Floor.
from ooodev.format.inner.preset.preset_gradient import PresetGradientKind
# ... other code
floor = chart_doc.first_diagram.floor
floor.style_area_gradient_from_preset(
preset=PresetGradientKind.DEEP_OCEAN,
)
The results are seen in Fig. 532 and Fig. 533
Fig. 532 Chart with gradient wall and floor
Fig. 533 Chart Wall Gradient Dialog
Apply a custom Gradient
The style_area_gradient()
method is called to set the background gradient of a Chart Wall/Floor.
Apply the preset gradient to wall and floor
Apply to wall.
from ooo.dyn.awt.gradient_style import GradientStyle
from ooodev.utils.data_type.color_range import ColorRange
from ooodev.utils.color import StandardColor
# ... other code
wall = chart_doc.first_diagram.wall
wall.style_area_gradient(
style=GradientStyle.LINEAR,
angle=45,
grad_color=ColorRange(StandardColor.BLUE_DARK3, StandardColor.BLUE_LIGHT2),
)
Apply to floor.
from ooo.dyn.awt.gradient_style import GradientStyle
from ooodev.utils.data_type.color_range import ColorRange
from ooodev.utils.color import StandardColor
# ... other code
floor = chart_doc.first_diagram.floor
floor.style_area_gradient(
style=GradientStyle.LINEAR,
angle=45,
grad_color=ColorRange(StandardColor.BLUE_DARK3, StandardColor.BLUE_LIGHT2),
)
The results are seen in Fig. 534
Fig. 534 Chart with custom gradient background
Image
The style_area_image_from_preset()
or style_area_image()
methods are called to set the background image of the Chart Wall/Floor.
Before applying formatting is seen in Fig. 830.
Apply image to wall and floor
The PresetImageKind
enum is used to select an image preset.
Apply to wall.
from ooodev.format.inner.preset.preset_image import PresetImageKind
# ... other code
wall = chart_doc.first_diagram.wall
wall.style_area_image_from_preset(preset=PresetImageKind.ICE_LIGHT)
Apply to floor.
from ooodev.format.inner.preset.preset_image import PresetImageKind
# ... other code
floor = chart_doc.first_diagram.floor
floor.style_area_image_from_preset(preset=PresetImageKind.ICE_LIGHT)
The results are seen in Fig. 535 and Fig. 536
Fig. 535 Chart with wall and floor image
Fig. 536 Chart Area Image Dialog
Pattern
The style_area_pattern_from_preset()
or style_area_pattern()
methods are called to set the background pattern of a Chart Wall/Floor.
Before applying formatting is seen in Fig. 830.
Apply background pattern of a Chart
The PresetPatternKind
enum is used to select a pattern preset.
Apply to wall.
from ooodev.format.inner.preset.preset_pattern import PresetPatternKind
# ... other code
wall = chart_doc.first_diagram.wall
wall.style_area_pattern_from_preset(preset=PresetPatternKind.ZIG_ZAG)
Apply to floor.
from ooodev.format.inner.preset.preset_pattern import PresetPatternKind
# ... other code
floor = chart_doc.first_diagram.floor
floor.style_area_pattern_from_preset(preset=PresetPatternKind.ZIG_ZAG)
The results are seen in Fig. 537 and Fig. 538
Fig. 537 Chart with wall and floor pattern
Fig. 538 Chart Wall Pattern Dialog
Hatch
The style_area_hatch_from_preset()
or style_area_hatch()
methods are called to set the background hatch of a Chart Wall/Floor.
Before applying formatting is seen in Fig. 830.
Apply background hatch of a Chart
The PresetHatchKind
enum is used to select a hatch preset.
Apply to wall.
from ooodev.format.inner.preset.preset_hatch import PresetHatchKind
# ... other code
wall = chart_doc.first_diagram.wall
wall.style_area_hatch_from_preset(preset=PresetHatchKind.BLUE_45_DEGREES)
Apply to floor.
from ooodev.format.inner.preset.preset_hatch import PresetHatchKind
# ... other code
floor = chart_doc.first_diagram.floor
floor.style_area_hatch_from_preset(preset=PresetHatchKind.BLUE_45_DEGREES)
The results are seen in Fig. 539 and Fig. 540
Fig. 539 Chart with wall and floor hatch
Fig. 540 Chart Area Hatch Dialog