You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Could I implement a color as a function (r,g,b)?

I want to create colour charts, and I need a function that would set a cell color as a function of the r,g,b values supplied.


I searched all the functions, but nothing exists, so I wondered if there’s a way to introduce this in numbers?


if not, does anyone know what spreads sheet might allow or have this?


Posted on Oct 5, 2024 10:58 PM

Reply
2 replies

Oct 6, 2024 4:16 AM in response to jerelo

Numbers does not have a native way to set color via RGB values.


It is possible to set the background color of cells using AppleScript or JXA.


For example, to set background of cell "A2" of Table 1 on Sheet 1 of the front document to red.


tell application "Numbers"
	tell sheet 1 of document 1
		tell cell "B2" of table 1
			set background color to {59149, 6, 3483}
		end tell
	end tell
end tell



Copy-paste into Script Editor in Applications > Utilities. If necessary make sure Script Editor has permissions in System Settings ... With the Numbers document open click the Run button in Script Editor.


But, to my knowledge, it is not possible to use AppleScript to set the color in charts.


SG

Oct 6, 2024 12:45 PM in response to SGIII

I agree with SGIII here... an AppleScript can set a cell's background color, but there's no built-in function to do this dynamically.


The script could easily extract values from cells to determine the RGB parameters, but as an external script, it would have to be invoked manually to update the sheet to reflect any changes, since it wouldn't automatically react/adjust to changes in the cell values.

Could I implement a color as a function (r,g,b)?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.