PHP Graphing LibraryPHPGraphLib

Lightweight PHP Graphing Library

New forums launched 11/19/2009! Please use the below forums to post your questions and issues for PHPGraphLib. No registration is necessary to post a topic.
Current User: Guest Login Register
Please consider registering

Search Forums:


 






UserPost

6:01 pm
March 15, 2010


Yetty

Guest

Hi,
I change a function returnColorArray. I add convert #XXXXXX or #XXX to color:

function returnColorArray($color)
{
/** #XXX or #XXXXXX to color */
if($color[0]=='#') {
$color = str_replace('#',", $color);
$length = (strlen($color) == 3) ? 1 : ((strlen($color) == 6) ? 2 : false);

if($length){
$out[0] = hexdec(str_repeat(substr($color, 0, 1*$length), 2/$length));
$out[1] = hexdec(str_repeat(substr($color, 1*$length, 1*$length), 2/$length));
$out[2] = hexdec(str_repeat(substr($color, 2*$length, 1*$length), 2/$length));

return $out;
}
}

//CHECK TO SEE IF NUMERIC COLOR PASSED THROUGH IN FORM '128,128,128′
if(strpos($color,',')!==false) {
return explode(',',$color);
}

switch(strtolower($color))
{
//NAMED COLORS BASED ON W3C's RECOMMENDED HTML COLORS
case 'black': return array(0,0,0); break;
case 'silver': return array(192,192,192); break;
case 'gray': return array(128,128,128); break;
case 'white': return array(255,255,255); break;
case 'maroon': return array(128,0,0); break;
case 'red': return array(255,0,0); break;
case 'purple': return array(128,0,128); break;
case 'fuscia': return array(255,0,255); break;
case 'green': return array(0,128,0); break;
case 'lime': return array(0,255,0); break;
case 'olive': return array(128,128,0); break;
case 'yellow': return array(255,255,0); break;
case 'navy': return array(0,0,128); break;
case 'blue': return array(0,0,255); break;
case 'teal': return array(0,128,128); break;
case 'aqua': return array(0,255,255); break;
}
$this->error[]="Color name "$color" not recogized.";
return false;
}

6:02 pm
March 15, 2010


Yetty

Guest

Nicer code: http://snipt.org/GIp

6:28 pm
March 15, 2010


Yetty

Guest

Second fix, change function addData, now there are max. 3, after my change it can be, how many you want: http://snipt.org/GJk

6:20 pm
March 22, 2010


Elliott Brueggeman

Admin

Thanks for the color code – I'll try and put this in a future release. Increasing the number of data sets is more tricky though. The beauty of the 3 limit is that the resulting graphs will always look and will be usable. When increasing to an arbitrary number of datasets, the bar chart is no longer usable. In addition, the legend needs to expand gracefully. I'm thinking of increasing the max datasets to 5, to cover most cases, but I don't think an arbitrary number is a good idea.

5:01 pm
April 22, 2010


Elliott Brueggeman

Admin

This feature has been added to the lastest version of PHPGraphLib. Download version 2.30 on the downloads page.

6:54 am
May 11, 2010


fier7

New Member

how to create different colors on a single data, rather than the multi-data????

5:30 pm
May 26, 2010


Jim

Guest

I like that one can specify different colors for the bar/line graphs. This would also be helpful for the pie charts instead of having to use the default colors. Please add this capability at time permits. Thanks!

Reply to Post


Reply to Topic:
Add color feature

Guest Name (Required):

Guest Email (Required):

Post New Reply

Guest URL (required)

Math Required!
What is the sum of:
7 + 6