Chart Axis Labels

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
saleem145
Posts: 130
Joined: Mon Jul 02, 2012 4:47 pm

Chart Axis Labels

Post by saleem145 »

Hello,

I am using version 3.1 of Open Office on Linux. I have created a plot but cannot seem to find how to attach an axis labels. Ideally I would like to do it programatically. I am able to set the title but cannot change the axis label...

I am trying

diagram = chartDoc.getDiagram()
xAxis = diagram.XAxis
xAxis.AxisTitle.String = "X Axis Label"

does not work....

Saleem
OpenOffice 3.4.0
Mac OS X 10.5.8
FJCC
Moderator
Posts: 9278
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Chart Axis Labels

Post by FJCC »

Try

Code: Select all

oDiagram = Chart.Diagram
XAxisTitle = oDiagram.XAxisTitle
XAxisTitle.String = "X Axis Label"
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
saleem145
Posts: 130
Joined: Mon Jul 02, 2012 4:47 pm

Re: Chart Axis Labels

Post by saleem145 »

No luck -- I am using python in an Addon if that makes a difference

diagram = chartDoc.Diagram
xAxisTitle = diagram.XAxisTitle
xAxisTitle.String = xlabel
OpenOffice 3.4.0
Mac OS X 10.5.8
FJCC
Moderator
Posts: 9278
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Chart Axis Labels

Post by FJCC »

This Python code works for me for adding an X axis title to an existing chart.

Code: Select all

import uno

def AddXAxisTitle():
  oDoc = XSCRIPTCONTEXT.getDocument()
  oSheets = oDoc.getSheets()
  oSheet= oSheets.getByIndex(0)
  oCharts = oSheet.getCharts()
  oChart = oCharts.getByIndex(0).EmbeddedObject
  oDiagram = oChart.Diagram
  oDiagram.XAxisTitle.String = 'New String'
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Post Reply