Chart2 Direct Axis Font Only (Static)
Overview
The ooodev.format.chart2.direct.axis.font.FontOnly
class gives you similar options
as Fig. 667 Font Dialog, but without the dialog.
Methods for formatting the number of an axis are:
See also
Setup
General setup for this example.
import uno
from ooodev.format.chart2.direct.axis.font import FontOnly as AxisFontOnly
from ooodev.format.chart2.direct.general.borders import LineProperties as ChartLineProperties
from ooodev.format.chart2.direct.general.area import Gradient as ChartGradient
from ooodev.format.chart2.direct.general.area import GradientStyle, ColorRange, Offset
from ooodev.office.calc import Calc
from ooodev.office.chart2 import Chart2
from ooodev.utils.color import StandardColor
from ooodev.gui import GUI
from ooodev.loader.lo import Lo
def main() -> int:
with Lo.Loader(connector=Lo.ConnectPipe()):
doc = Calc.open_doc(Path.cwd() / "tmp" / "bon_voyage.ods")
GUI.set_visible(True, doc)
Lo.delay(500)
Calc.zoom(doc, GUI.ZoomEnum.ZOOM_100_PERCENT)
sheet = Calc.get_active_sheet()
Calc.goto_cell(cell_name="A1", doc=doc)
chart_doc = Chart2.get_chart_doc(sheet=sheet, chart_name="Object 1")
chart_bdr_line = ChartLineProperties(color=StandardColor.GREEN_DARK2, width=0.9)
chart_grad = ChartGradient(
chart_doc=chart_doc,
step_count=0,
offset=Offset(41, 50),
style=GradientStyle.RADIAL,
grad_color=ColorRange(StandardColor.TEAL, StandardColor.YELLOW_DARK1),
)
Chart2.style_background(chart_doc=chart_doc, styles=[chart_grad, chart_bdr_line])
axis_font = AxisFontOnly(name="Lucida Calligraphy", size=14, font_style="italic")
Chart2.style_y_axis(chart_doc=chart_doc, styles=[axis_font])
Lo.delay(1_000)
Lo.close_doc(doc)
return 0
if __name__ == "__main__":
SystemExit(main())
Apply Font Only
Before formatting the chart is seen in Fig. 827.
Apply to Y-Axis
from ooodev.format.chart2.direct.axis.font import FontOnly as AxisFontOnly
# ... other code
axis_font = AxisFontOnly(name="Lucida Calligraphy", size=14, font_style="italic")
Chart2.style_y_axis(chart_doc=chart_doc, styles=[axis_font])
Running the above code will produce the following output shown in Fig. 666 and Fig. 667.
Apply to X-Axis
# ... other code
Chart2.style_X_axis(chart_doc=chart_doc, styles=[axis_font])
Running the above code will produce the following output shown in Fig. 668.