Chart2 Direct General Transparency

Overview

The style_area_transparency_*() method can be used to set chart transparency.

Setup

General setup for examples.

from __future__ import annotations
import uno
from pathlib import Path
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_area_color(color=StandardColor.GREEN_LIGHT2)
        _ = chart_doc.style_area_transparency_transparency(50)

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


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

Transparency

Before setting the background transparency of the chart is seen in Fig. 829.

Setting Transparency

The style_area_transparency_transparency() method can be used to set the transparency of a chart.

_ = chart_doc.style_area_color(color=StandardColor.GREEN_LIGHT2)
_ = chart_doc.style_area_transparency_transparency(50)

The results can bee seen in Fig. 480 and Fig. 481.

Chart with border, color and  transparency

Fig. 480 Chart with border, color and transparency

Chart Area Transparency Dialog

Fig. 481 Chart Area Transparency Dialog

Getting the transparency from a Chart

# ... other code

f_style = chart_doc.style_area_transparency_transparency_get()
assert f_style is not None

Gradient Transparency

Before setting the background gradient transparency of the chart is seen in Fig. 829.

Setting Gradient

The style_area_transparency_gradient() method can be used to set the gradient transparency of a chart.

from ooodev.utils.data_type.intensity_range import IntensityRange
# ... other code

_ = chart_doc.style_area_transparency_gradient(angle=30, grad_intensity=IntensityRange(0, 100))

The results can bee seen in Fig. 482 and Fig. 483.

Chart with border, color and  transparency

Fig. 482 Chart with border, color and transparency

Chart Area Transparency Dialog

Fig. 483 Chart Area Transparency Dialog