[Solved] Use the contents of a cell as a chart title?

Discuss the spreadsheet application
Post Reply
NLRobinson
Posts: 2
Joined: Tue Mar 08, 2011 8:09 pm

[Solved] Use the contents of a cell as a chart title?

Post by NLRobinson »

I have a monthly graph that I use to report payroll averages and want to have a title or subtitle in the graph that is equal to my date range specified in cell b3. I haven't been able to find a way to make the contents of a cell the title of subtitle of my chart. Any ideas?

Thanks for your help.

OOo 3.2.1, Windows 8.1
Last edited by MrProgrammer on Sat Oct 31, 2020 5:52 pm, edited 1 time in total.
Reason: Tagged ✓ [Solved]
OpenOffice 3.3 on Windows Vista
User avatar
Charlie Young
Volunteer
Posts: 1559
Joined: Fri May 14, 2010 1:07 am

Re: How do I use the contents of a cell as a chart title?

Post by Charlie Young »

From Calc Help:
It is not possible to link the title text to a cell. You must enter the text directly.
It would probably be possible to do something with a macro, but methinks it would get tricky to have something that automatically changed the titles when the cell content changes.
Apache OpenOffice 4.1.1
Windows XP
User avatar
keme
Volunteer
Posts: 3789
Joined: Wed Nov 28, 2007 10:27 am
Location: Egersund, Norway

Re: How do I use the contents of a cell as a chart title?

Post by keme »

Workaround: Use a cell to display the title. See attached file, where the D15 "chart title" cell uses a link to the table title in A1. With coloured background in the cells and transparency on the chart background, it doesn't look too bad. (I will not insist that you use that colour. It was chosen at random. :) )
Attachments
Dynamic title.ods
(18.64 KiB) Downloaded 1815 times
Apache OO 4.1.12 and LibreOffice 7.5, mostly on Ms Windows 10
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: How do I use the contents of a cell as a chart title?

Post by acknak »

Nice idea! Clever workaround.
AOO4/LO5 • Linux • Fedora 23
User avatar
Villeroy
Volunteer
Posts: 31362
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: How do I use the contents of a cell as a chart title?

Post by Villeroy »

Bind a text box from toolbar "Form Controls" to a cell and place it in front of the chart.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Zizi64
Volunteer
Posts: 11505
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: How do I use the contents of a cell as a chart title?

Post by Zizi64 »

Here is an another idea... (user defined macro function):

Code: Select all

Function SetGraphTitle(GraphName as string,TitleString as string) as string

Dim Doc As Object
Dim Charts As Object
Dim Chart as Object
Dim NumberOfCharts as integer
Dim i as integer


Doc = StarDesktop.CurrentComponent
Charts = Doc.Sheets(0).Charts
NumberOfCharts = Charts.Count
'Print NumberOfCharts

SetGraphTitle = "Chart named '" + GraphName + "' is missing"

For i = 0 to NumberOfCharts-1
	Chart = Charts(i)
	'Print Chart.Name 
	If Chart.Name = GraphName then
		Chart = Charts.getByName(GraphName).embeddedObject
		Chart.HasMainTitle = True
		Chart.Title.String = TitleString
		SetGraphTitle = "OK"
	end if
Next i

end function
You must use the primer (inner) names of Charts (OLE objects): «Object 1», etc.
(Delete any custom Chart names such «MyGraph003»)

I feel that, there is some bug about the handling of the chart names:
When you create a chart by a Macro, the programatically given name will rewrite the «inner» name of chart, and then you can get the chart by its macro defined name.
But when you create a chart manually, and you edit the NAME of chart, then you can not get the chart by a macro based on its displayed name.
If you delete the user defined name, the «name» will reset to the «inner» name, and you can get the chart by macro again by the displayed name.

(Use the Navigator to display the actual names of the Charts – or names of the OLE objects.
Dynamic title2.ods
(46.24 KiB) Downloaded 318 times
Tibor Kovacs, Hungary; LO7.5.8/25.8.5.2 /Win7-10-11 x64Prof.
PortableApps: LO3.3.0-25.8.5.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Post Reply