Chart2 Direct Wall/Floor Area (Static)
Overview
The ooodev.format.chart2.direct.wall
module is used to format the wall/floor of a Chart.
See also
Setup
General setup for examples.
import uno
from ooodev.format.chart2.direct.wall.area import Color as WallColor
from ooodev.format.chart2.direct.general.borders import LineProperties as ChartLineProperties
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_chart3d.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_DARK1, width=1.0)
Chart2.style_background(chart_doc=chart_doc, styles=[chart_bdr_line])
wall_color = WallColor(color=StandardColor.DEFAULT_BLUE)
Chart2.style_wall(chart_doc=chart_doc, styles=[wall_color])
Lo.delay(1_000)
Lo.close_doc(doc)
return 0
if __name__ == "__main__":
SystemExit(main())
Color
The ooodev.format.chart2.direct.general.area.Color
class is used to set the background color of a Chart.
Before applying formatting is seen in Fig. 830.
Apply the background color to a wall and floor
Apply to wall.
from ooodev.format.chart2.direct.wall.area import Color as WallColor
# ... other code
# wall color
wall_color = WallColor(color=StandardColor.DEFAULT_BLUE)
Chart2.style_wall(chart_doc=chart_doc, styles=[wall_color])
Apply to floor.
# floor color
floor_color = WallColor(color=StandardColor.BLUE_DARK1)
Chart2.style_floor(chart_doc=chart_doc, styles=[floor_color])
Gradient
The ooodev.format.chart2.direct.wall.area.Gradient
class is used to set the background gradient of a Chart.
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.chart2.direct.wall.area import Gradient as WallGradient, PresetGradientKind
# ... other code
wall_grad = WallGradient.from_preset(chart_doc, PresetGradientKind.DEEP_OCEAN)
Chart2.style_wall(chart_doc=chart_doc, styles=[wall_grad])
Apply to Floor.
floor_grad = WallGradient.from_preset(chart_doc, PresetGradientKind.MIDNIGHT)
Chart2.style_floor(chart_doc=chart_doc, styles=[floor_grad])
Apply a custom Gradient
Demonstrates how to create a custom gradient.
Apply the preset gradient to wall and floor
Apply to wall.
from ooodev.format.chart2.direct.wall.area import Gradient as WallGradient, GradientStyle
from ooodev.format.chart2.direct.wall.area import ColorRange
# ... other code
wall_grad = WallGradient(
chart_doc=chart_doc,
style=GradientStyle.LINEAR,
angle=45,
grad_color=ColorRange(StandardColor.BLUE_DARK3, StandardColor.BLUE_LIGHT2),
)
Chart2.style_wall(chart_doc=chart_doc, styles=[wall_grad])
Apply to floor.
floor_grad = WallGradient(
chart_doc=chart_doc,
style=GradientStyle.LINEAR,
angle=-10,
grad_color=ColorRange(StandardColor.BLUE_DARK4, StandardColor.BLUE),
)
Chart2.style_floor(chart_doc=chart_doc, styles=[floor_grad])
The results are seen in Fig. 713
Image
The ooodev.format.chart2.direct.wall.area.Img
class is used to set the background image of the wall and 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.chart2.direct.wall.area import Img as WallImg, PresetImageKind
# ... other code
wall_img = WallImg.from_preset(chart_doc, PresetImageKind.ICE_LIGHT)
Chart2.style_wall(chart_doc=chart_doc, styles=[wall_img])
Apply to floor.
floor_img = WallImg.from_preset(chart_doc, PresetImageKind.MARBLE)
Chart2.style_floor(chart_doc=chart_doc, styles=[floor_img])
Pattern
The ooodev.format.chart2.direct.wall.area.Pattern
class is used to set the background pattern of a Chart.
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.chart2.direct.wall.area import Pattern as WallPattern, PresetPatternKind
# ... other code
wall_pattern = WallPattern.from_preset(chart_doc, PresetPatternKind.ZIG_ZAG)
Chart2.style_wall(chart_doc=chart_doc, styles=[wall_pattern])
Apply to floor.
floor_pattern = WallPattern.from_preset(chart_doc, PresetPatternKind.PERCENT_20)
Chart2.style_floor(chart_doc=chart_doc, styles=[floor_pattern])
Hatch
The ooodev.format.chart2.direct.wall.area.Hatch
class is used to set the background hatch of a Chart.
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.chart2.direct.wall.area import Hatch as WallHatch, PresetHatchKind
# ... other code
wall_hatch = WallHatch.from_preset(chart_doc, PresetHatchKind.BLUE_45_DEGREES_CROSSED)
Chart2.style_wall(chart_doc=chart_doc, styles=[wall_hatch])
Apply to floor.
floor_hatch = WallHatch.from_preset(chart_doc, PresetHatchKind.BLUE_45_DEGREES)
Chart2.style_floor(chart_doc=chart_doc, styles=[floor_hatch])