Chart2 Direct Axis Line (Static)

Overview

The ooodev.format.chart2.direct.axis.line.LineProperties class gives the same options as seen in Fig. 670.

Methods for formatting the number of an axis are:

Setup

import uno
from ooodev.format.chart2.direct.axis.line import LineProperties as AxisLineProperties
from ooodev.format.chart2.direct.general.borders import LineProperties as ChartLineProperties
from ooodev.format.chart2.direct.general.area import Gradient as ChartGradient
from ooodev.format.chart2.direct.general.area import GradientStyle, ColorRange, Offset
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(Path.cwd() / "tmp" / "bon_voyage.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="Object 1")

        chart_bdr_line = ChartLineProperties(color=StandardColor.GREEN_DARK2, width=0.9)
        chart_grad = ChartGradient(
            chart_doc=chart_doc,
            step_count=0,
            offset=Offset(41, 50),
            style=GradientStyle.RADIAL,
            grad_color=ColorRange(StandardColor.TEAL, StandardColor.YELLOW_DARK1),
        )
        Chart2.style_background(chart_doc=chart_doc, styles=[chart_grad, chart_bdr_line])

        axis_line_props = AxisLineProperties(color=StandardColor.TEAL, width=0.75)
        Chart2.style_x_axis(chart_doc=chart_doc, styles=[axis_line_props])

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

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

Apply Line to Axis

The LineProperties class is used to set the Axis line properties.

Before formatting the chart is seen in Fig. 827.

Apply to Y-Axis

from ooodev.format.chart2.direct.axis.line import LineProperties as AxisLineProperties
# ... other code

axis_line_props = AxisLineProperties(color=StandardColor.TEAL, width=0.75)
Chart2.style_y_axis(chart_doc=chart_doc, styles=[axis_line_props])

The results are seen in Fig. 669 and Fig. 670

Chart with Y-Axis line set

Fig. 669 Chart with Y-Axis line set

Chart Y-Axis Line Dialog

Fig. 670 Chart Y-Axis Line Dialog

Apply to X-Axis

# ... other code

Chart2.style_x_axis(chart_doc=chart_doc, styles=[axis_line_props])

The results are seen in Fig. 671

Chart with Y-Axis line set

Fig. 671 Chart with Y-Axis line set