Chart2 Direct Series Data Series Borders

Overview

The Data Series and Data Point of a Chart can be styled using the various style_* methods of the ChartDataSeries and ChartDataPoint classes.

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_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_border_line() method is called to set the data series border line properties.

Before formatting the chart is seen in Fig. 829.

Style Data Series

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

The results are seen in Fig. 564 and Fig. 565.

Chart with data series border set

Fig. 564 Chart with data series border set

Chart Data Series Borders Default Dialog

Fig. 565 Chart Data Series Borders Default Dialog

Style Data Point

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

The results are seen in Fig. 566.

Chart with data point border set

Fig. 566 Chart with data point border set