Page 1 of 1

Chart Axis Labels

Posted: Tue Dec 18, 2012 4:43 pm
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

Re: Chart Axis Labels

Posted: Tue Dec 18, 2012 5:35 pm
by FJCC
Try

Code: Select all

oDiagram = Chart.Diagram
XAxisTitle = oDiagram.XAxisTitle
XAxisTitle.String = "X Axis Label"

Re: Chart Axis Labels

Posted: Tue Dec 18, 2012 6:31 pm
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

Re: Chart Axis Labels

Posted: Tue Dec 18, 2012 8:11 pm
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'