cancel
Showing results for 
Search instead for 
Did you mean: 

extracting pen colours in hex

Former Member
0 Kudos

Hi

I want to take the colour from a range in custom chart and use it to set the backgroundColor of a cell in an HTML table.

I tried

var graph=document.appGraph.getChartObject()

tab1.rows[1].cells[1].style.backgroundColor = graph.getPenColor(1)

but it doesn't work, because the getPenColor returns the following

java.awt.Color[r=255,g=0,b=0]

how do I either return a hex colour code, or convert this to a hex code?

Thanks

Nick

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Found it!

color = graph.getPenColor(1)

colorString="rgb(" + color.getRed() + "," + color.getGreen() + "," + color.getBlue() + ")"

tab1.rows[1].cells[1].style.backgroundColor = colorString

jcgood25
Active Contributor
0 Kudos

Or since you already have an applet there you can use one of the base applet convenience methods which will make the string for you from the color object:

document.iChart.colorToString(COLOR);

Regards,

Jeremy

Former Member
0 Kudos

Thanks

Never spotted that one.