function pData::setPalette

5.x pData.class.php pData::setPalette($Series, $Format = NULL)

File

inc/pchart/pchart/class/pData.class.php, line 501

Class

pData

Code

function setPalette($Series, $Format = NULL) 
 {
  if (!is_array($Series)) {
    $Series = $this->convertToArray($Series);
  }

  foreach ($Series as $Key => $Serie) 
   {
    $R = isset($Format ["R"]) ? $Format ["R"] : 0;
    $G = isset($Format ["G"]) ? $Format ["G"] : 0;
    $B = isset($Format ["B"]) ? $Format ["B"] : 0;
    $Alpha = isset($Format ["Alpha"]) ? $Format ["Alpha"] : 100;

    if (isset($this->Data ["Series"][$Serie])) 
     {
      $OldR = $this->Data ["Series"][$Serie]["Color"]["R"];
      $OldG = $this->Data ["Series"][$Serie]["Color"]["G"];
      $OldB = $this->Data ["Series"][$Serie]["Color"]["B"];
      $this->Data ["Series"][$Serie]["Color"]["R"] = $R;
      $this->Data ["Series"][$Serie]["Color"]["G"] = $G;
      $this->Data ["Series"][$Serie]["Color"]["B"] = $B;
      $this->Data ["Series"][$Serie]["Color"]["Alpha"] = $Alpha;

      /* Do reverse processing on the internal palette array */
      foreach ($this->Palette as $Key => $Value) 
       {
        if ($Value ["R"] == $OldR && $Value ["G"] == $OldG && $Value ["B"] == $OldB) {
          $this->Palette [$Key]["R"] = $R;
          $this->Palette [$Key]["G"] = $G;
          $this->Palette [$Key]["B"] = $B;
          $this->Palette [$Key]["Alpha"] = $Alpha;
        }
      }
    }
  }
}