function get_next_palette($palette = 0, $palettetype = 0)
{
    static $prev_color = array(0, 0, 0, 0);
    switch ($palette) {
        case 0:
            $palettes = array(array(150, 0, 0), array(0, 100, 150), array(170, 180, 180), array(152, 100, 0), array(130, 0, 150), array(0, 0, 150), array(200, 100, 50), array(250, 40, 40), array(50, 150, 150), array(100, 150, 0));
            break;
        case 1:
            $palettes = array(array(0, 100, 150), array(153, 0, 30), array(100, 150, 0), array(130, 0, 150), array(0, 0, 100), array(200, 100, 50), array(152, 100, 0), array(0, 100, 0), array(170, 180, 180), array(50, 150, 150));
            break;
        case 2:
            $palettes = array(array(170, 180, 180), array(152, 100, 0), array(50, 200, 200), array(153, 0, 30), array(0, 0, 100), array(100, 150, 0), array(130, 0, 150), array(0, 100, 150), array(200, 100, 50), array(0, 100, 0));
            break;
        case 3:
        default:
            return get_next_color($palettetype);
    }
    if (isset($palettes[$prev_color[$palette]])) {
        $result = $palettes[$prev_color[$palette]];
    } else {
        return get_next_color($palettetype);
    }
    switch ($palettetype) {
        case 0:
            $diff = 0;
            break;
        case 1:
            $diff = -50;
            break;
        case 2:
            $diff = 50;
            break;
    }
    foreach ($result as $n => $color) {
        if ($color + $diff < 0) {
            $result[$n] = 0;
        } elseif ($color + $diff > 255) {
            $result[$n] = 255;
        } else {
            $result[$n] += $diff;
        }
    }
    $prev_color[$palette]++;
    return $result;
}
Beispiel #2
0
$graph = new CLineGraphDraw(getRequest('type'));
$graph->setPeriod($timeline['period']);
$graph->setSTime($timeline['stime']);
// change how the graph will be displayed if more than one item is selected
if (getRequest('batch')) {
    // set a default header
    if (count($hostNames) == 1) {
        $graph->setHeader($hostNames[0] . NAME_DELIMITER . _('Item values'));
    } else {
        $graph->setHeader(_('Item values'));
    }
    // hide triggers
    $graph->showTriggers(false);
}
if (isset($_REQUEST['from'])) {
    $graph->setFrom($_REQUEST['from']);
}
if (isset($_REQUEST['width'])) {
    $graph->setWidth($_REQUEST['width']);
}
if (isset($_REQUEST['height'])) {
    $graph->setHeight($_REQUEST['height']);
}
if (isset($_REQUEST['border'])) {
    $graph->setBorder(0);
}
foreach ($items as $item) {
    $graph->addItem($item['itemid'], GRAPH_YAXIS_SIDE_DEFAULT, getRequest('batch') ? CALC_FNC_AVG : CALC_FNC_ALL, rgb2hex(get_next_color(1)));
}
$graph->draw();
require_once dirname(__FILE__) . '/include/page_footer.php';
/**
 * Gets the next Channel Color.
 *
 * @global object $mydatabase mysql database object.
 *
 * @return string  the hex of the next color
 */
function get_next_color_ordered($whichone)
{
    global $mydatabase, $CSLH_Config;
    $sqlquery = "SELECT * FROM livehelp_operator_channels";
    $rows = $mydatabase->query($sqlquery);
    if (empty($CSLH_Config['chatcolors'])) {
        $CSLH_Config['chatcolors'] = "fefdcd,cbcefe,caedbe,cccbba,aecddc,fafafb,faacaa,fbddef,cfaaef,aedcbd,bbffff,fedabf;040662,240462,462040,404062,604000,662640,242642,464406,404060,442662,442022,200220;426446,224646,466286,828468,866482,484668,888286,224882,486882,824864,668266,444468";
    }
    $sequences = preg_split("/;/", $CSLH_Config['chatcolors']);
    $nextcolor = get_next_color($whichone);
    if ($whichone == "backgrounds") {
        $colors = preg_split("/,/", $sequences[0]);
    }
    if ($whichone == "clients") {
        $colors = preg_split("/,/", $sequences[1]);
    }
    if ($whichone == "operators") {
        $colors = preg_split("/,/", $sequences[2]);
    }
    $index = $rows->numrows();
    if ($index < count($colors)) {
        $nextcolor = $colors[$index];
        if ($whichone == "backgrounds") {
            $sqlquery = "SELECT * FROM livehelp_operator_channels WHERE channelcolor='{$nextcolor}'";
        }
        if ($whichone == "clients") {
            $sqlquery = "SELECT * FROM livehelp_operator_channels WHERE txtcolor_alt='{$txtcolor_alt}'";
        }
        if ($whichone == "operators") {
            $sqlquery = "SELECT * FROM livehelp_operator_channels WHERE txtcolor='{$txtcolor}'";
        }
        $checkrows = $mydatabase->query($sqlquery);
        while ($index < count($colors) && $checkrows->numrows() != 0) {
            $index++;
            $nextcolor = $colors[$index];
            if ($whichone == "backgrounds") {
                $sqlquery = "SELECT * FROM livehelp_operator_channels WHERE channelcolor='{$nextcolor}'";
            }
            if ($whichone == "clients") {
                $sqlquery = "SELECT * FROM livehelp_operator_channels WHERE txtcolor_alt='{$txtcolor_alt}'";
            }
            if ($whichone == "operators") {
                $sqlquery = "SELECT * FROM livehelp_operator_channels WHERE txtcolor='{$txtcolor}'";
            }
            $checkrows = $mydatabase->query($sqlquery);
        }
    } else {
        $nextcolor = get_next_color($whichone);
    }
    if ($whichone == "backgrounds") {
        $sqlquery = "SELECT * FROM livehelp_operator_channels WHERE channelcolor='{$nextcolor}'";
    }
    if ($whichone == "clients") {
        $sqlquery = "SELECT * FROM livehelp_operator_channels WHERE txtcolor_alt='{$txtcolor_alt}'";
    }
    if ($whichone == "operators") {
        $sqlquery = "SELECT * FROM livehelp_operator_channels WHERE txtcolor='{$txtcolor}'";
    }
    $checkrows = $mydatabase->query($sqlquery);
    if ($checkrows->numrows() != 0) {
        $nextcolor = get_next_color($whichone);
    }
    return $nextcolor;
}