Chart2 Direct Series Data Labels Borders

Overview

The style_label_border_line() method gives the same options as the Chart Data Labels Border dialog as seen in Fig. 765.

Setup

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
from ooodev.format.inner.preset.preset_gradient import PresetGradientKind

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_LIGHT3,
            width=0.7,
        )
        _ = chart_doc.style_area_gradient_from_preset(
            preset=PresetGradientKind.TEAL_BLUE,
        )
        ds = chart_doc.get_data_series()[0]
        ds.style_label_border_line(
            color=StandardColor.MAGENTA_DARK1,
            width=0.75,
        )

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

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

Setting Line Properties

The style_label_border_line() method is used to set the data labels border line properties.

Before formatting the chart is seen in Fig. 829.

Style Data Series

Setting Style

# ... other code
ds.style_label_border_line(
    color=StandardColor.MAGENTA_DARK1,
    width=0.75,
)

The results are seen in Fig. 585 and Fig. 586

Chart with series data labels border set

Fig. 585 Chart with series data labels border set

Chart Data Labels Borders Default Dialog

Fig. 586 Chart Data Labels Borders Default Dialog

Getting Style

# ... other code
f_style = ds.style_label_border_line_get()
assert f_style is not None

Style Data Point

Setting Style

# ... other code
ds = chart_doc.get_data_series()[0]
dp = ds[2]
dp.style_label_border_line(
    color=StandardColor.MAGENTA_DARK1,
    width=0.75,
)

The results are seen in Fig. 587.

Chart with point data labels border set

Fig. 587 Chart with point data labels border set

Getting Style

# ... other code
f_style = dp.style_label_border_line_get()
assert f_style is not None