Chart2 Direct Series Data Labels Font Effects
Overview
The ooodev.format.chart2.direct.series.data_labels.font.FontEffects
class gives you the similar options for data labels
as Fig. 786 Font Effects Dialog, but without the dialog.
Calls to the Chart2.style_data_series()
and Chart2.style_data_point()
methods are used to set the data labels font effects of a Chart.
Setup
General setup for this example.
from __future__ import annotations
from pathlib import Path
import uno
from ooo.dyn.awt.font_underline import FontUnderlineEnum
from ooodev.calc import CalcDoc, ZoomKind
from ooodev.loader.lo import Lo
from ooodev.format.inner.preset.preset_gradient import PresetGradientKind
from ooodev.utils.color import StandardColor
from ooodev.format.inner.direct.write.char.font.font_effects import FontLine
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_font_effect(
color=StandardColor.RED,
underline=FontLine(line=FontUnderlineEnum.SINGLE, color=StandardColor.BLUE),
shadowed=True,
)
Lo.delay(1_000)
doc.close()
return 0
if __name__ == "__main__":
SystemExit(main())
Apply the font effects to the data labels
Before formatting the chart is seen in Fig. 829.
Style Data Series
from ooo.dyn.awt.font_underline import FontUnderlineEnum
from ooodev.format.inner.direct.write.char.font.font_effects import FontLine
# ... other code
ds = chart_doc.get_data_series()[0]
ds.style_font_effect(
color=StandardColor.RED,
underline=FontLine(
line=FontUnderlineEnum.SINGLE, color=StandardColor.BLUE
),
shadowed=True,
)
Running the above code will produce the following output in Fig. 604 and Fig. 605.
Style Data Point
# ... other code
ds = chart_doc.get_data_series()[0]
dp = ds[4]
dp.style_font_effect(
color=StandardColor.RED,
underline=FontLine(line=FontUnderlineEnum.SINGLE, color=StandardColor.BLUE),
shadowed=True,
)
Running the above code will produce the following output in Fig. 606.