Chart2 Direct Series Data Series Transparency
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
General setup for examples.
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_area_transparency_transparency(50)
Lo.delay(1_000)
doc.close()
return 0
if __name__ == "__main__":
SystemExit(main())
Transparency
Before formatting the chart is seen in Fig. 829.
Setting Transparency
The style_area_transparency_transparency()
method can be called to set the data series transparency of a chart.
Style Data Series
# ... other code
ds = chart_doc.get_data_series()[0]
ds.style_area_transparency_transparency(50)
Style Data Point
# ... other code
ds = chart_doc.get_data_series()[0]
dp = ds[-1]
dp.style_area_transparency_transparency(50)
The results can bee seen in Fig. 581.
Gradient Transparency
Before formatting the chart is seen in Fig. 829.
Setting Gradient
The style_area_transparency_gradient()
method can be called to set the data series gradient transparency of a chart.
Style Data Series
from ooodev.utils.data_type.intensity_range import IntensityRange
from ooodev.utils.data_type.angle import Angle
# ... other code
ds = chart_doc.get_data_series()[0]
ds.style_area_transparency_gradient(
angle=30,
grad_intensity=IntensityRange(0, 100),
)
Style Data Point
from ooodev.utils.data_type.intensity_range import IntensityRange
# ... other code
ds = chart_doc.get_data_series()[0]
dp = ds[-1]
dp.style_area_transparency_gradient(
angle=30,
grad_intensity=IntensityRange(0, 100),
)
The results can bee seen in Fig. 584.