Chart2 Direct Grid Line Properties (Static)

Overview

The ooodev.format.chart2.direct.grid.LineProperties class can be used to set the line properties of a chart grid.

Setup

General setup for examples.

import uno
from ooodev.format.chart2.direct.general.area import Color as ChartColor
from ooodev.format.chart2.direct.general.borders import LineProperties as ChartLineProperties
from ooodev.format.chart2.direct.grid import BorderLineKind
from ooodev.format.chart2.direct.grid import LineProperties as GridLineProperties
from ooodev.office.calc import Calc
from ooodev.office.chart2 import Chart2, AxisKind
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_DARK2, width=0.7)
        chart_color = ChartColor(color=StandardColor.DEFAULT_BLUE)
        Chart2.style_background(chart_doc=chart_doc, styles=[chart_color, chart_bdr_line])

        grid_style = GridLineProperties(
            style=BorderLineKind.CONTINUOUS, color=StandardColor.RED, width=0.5
        )
        Chart2.style_grid(chart_doc=chart_doc, axis_val=AxisKind.Y, styles=[grid_style])

        Lo.delay(1_000)
        Lo.close_doc(doc)
    return 0

if __name__ == "__main__":
    SystemExit(main())

Setting Grid Line Properties

Before setting chart formatting is seen in Fig. 829.

The formatting is applied to the y-axis (axis_val=AxisKind.Y) of the grid with a call to Chart2.set_grid_lines(). 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.

grid_style = GridLineProperties(
    style=BorderLineKind.CONTINUOUS, color=StandardColor.RED, width=0.5
)
Chart2.style_grid(chart_doc=chart_doc, axis_val=AxisKind.Y, styles=[grid_style])

The results are seen in Fig. 682 and Fig. 683

Chart with border set to green

Fig. 682 Chart with border set to green

Chart Area Borders Default Dialog Modified

Fig. 683 Chart Area Borders Default Dialog Modified