Chart2 Direct Grid Line Properties
Overview
The style_gird_line()
method can be used to set the line properties of a chart grid.
Setup
General setup for examples.
from __future__ import annotations
from pathlib import Path
import uno
from ooodev.format.inner.preset.preset_border_line import BorderLineKind
from ooodev.calc import CalcDoc, ZoomKind
from ooodev.utils.color import StandardColor
from ooodev.loader.lo import Lo
def main() -> int:
with Lo.Loader(connector=Lo.ConnectPipe()):
fnm = Path.cwd() / "tmp" / "col_chart.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.BLUE_DARK2,
width=0.7,
)
_ = chart_doc.style_area_color(color=StandardColor.DEFAULT_BLUE)
chart_doc.axis_y.style_gird_line(
style=BorderLineKind.CONTINUOUS,
color=StandardColor.RED,
width=0.5,
)
Lo.delay(1_000)
doc.close()
return 0
if __name__ == "__main__":
SystemExit(main())
Setting Grid Style
Before setting chart formatting is seen in Fig. 829.
The formatting is applied to the y-axis of the grid with a call to style_gird_line()
.
The BorderLineKind
enum is used to select the line style.
The StandardColor
enum is used to select the line color.
The line width is set to 0.5
millimeters.
from ooodev.format.inner.preset.preset_border_line import BorderLineKind
# ... other code
chart_doc.axis_y.style_gird_line(
style=BorderLineKind.CONTINUOUS,
color=StandardColor.RED,
width=0.5,
)
Getting Grid Style
You can get the font style using the style_gird_line_get()
method.
# ... other code
f_style = chart_doc.axis_y.style_gird_line_get()
assert f_style is not None