[Solved] [Calc] Modifing Chart Data Range

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
kebab4you
Posts: 7
Joined: Thu Jul 09, 2015 4:40 pm

[Solved] [Calc] Modifing Chart Data Range

Post by kebab4you »

Like the title says I'm having problem with modifying the data range of an existing chart. Most documentation I can find only touches upon how to create charts not modify them.

What I'm trying to do is tell an existing chart that its data range should be current + one row. Where a new row represent a new entry.

I found this site: http://computing.ingreatway.com/2013/11 ... geaddress/ that contained an example on how to do it but couldn't get it to work.
Last edited by kebab4you on Thu Jul 09, 2015 5:43 pm, edited 1 time in total.
OpenOffice 4.1.1
Windows 7
FJCC
Moderator
Posts: 9646
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: [Calc] Modifing Chart Data Range

Post by FJCC »

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.
kebab4you
Posts: 7
Joined: Thu Jul 09, 2015 4:40 pm

Re: [Calc] Modifing Chart Data Range

Post by kebab4you »

Seems to be what I'm looking for. Will give it a try.

Edit: It worked perfectly! I got an extra question though. I can never seem to find my charts by using the findByName function. These are chart that I did not create programmatically so how do I give them a name?
OpenOffice 4.1.1
Windows 7
FJCC
Moderator
Posts: 9646
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: [Solved][Calc] Modifing Chart Data Range

Post by FJCC »

I don't see a way to assign a name to a chart with the user interface. The name seems to get assigned automatically with no chance to modify it. If you right click on the chart and select Name you can assign a value to the DisplayName property that a macro can access like this

Code: Select all

  oSheets = ThisComponent.getSheets()
  oObj1 = oSheets.getByName("Hoja1")
  oCharts = oObj1.getCharts()
  
  oObj2 = oCharts.getByName("Object 1")
  print oObj2.DisplayName
You could iterate through the charts using getByIndex() and check the DisplayName to find out which chart you have.
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