|
Colors with the 0x |
Posted by Passing Colors into a BarLayer on Sep-28-2011 06:42 |
|
I am making a multi-color bar graph using BarLayer3(). I have color data stored in my
database in the format 123abc. Your color function expects it in format 0x123abc. If I try
to construct the color values using "0x$color" (in php, obviously), I get all black bars --
presumably because the new color value is a string. I can't add the 0x to my database
because I also use it to contextually drive the colors on my web page in other places by
prepending a "#" (i.e. "#123abc").
How do I pass in the colors without the 0x on the front (which is really unnecessary, by the
way). Alternately, how can I construct that string using "0x$color" and then convert it back
to the hex value your function is expecting? |
Re: Colors with the 0x |
Posted by Peter Kwan on Sep-28-2011 18:03 |
|
Hi,
ChartDirector does not expect or need "0x" in the color. It just needs the color to be an integer.
123abc is not an integer as acccording to PHP language syntax. (In fact, it is a PHP syntax error.) 0x123abc is an integer as according to PHP language syntax. In other words, 0x is a requirement of PHP, and is not related to ChartDirector. Any PHP integer formats will work with ChartDirector (not necessarily starting with 0x). See:
http://www.php.net/manual/en/language.types.integer.php
Note that "0x123abc" (with quotes) is not an integer as according to PHP syntax. It is a text string. If you use "0x123abc", in numeric context it will be coerced to 0 as per PHP syntax, so it is the black color.
If you have "123abc" (a text string), the PHP function to convert it to an integer is hexdec. See:
http://php.net/manual/en/function.hexdec.php
For example:
$myColor = hexdec("123abc");
Hope this can help.
Regards
Peter Kwan |
Re: Colors with the 0x |
Posted by Dave Mark on Sep-28-2011 21:18 |
|
Ding! That did it. Thanks... |
|