fabian
New pChart user
Joined: Fri Jul 13, 2012 2:11 pm Posts: 1
|
Bug in pBubble::drawBubbleChart & pData::setPalette (v2.1.3)
Hey, i think i've found a bug in above-named functions. My issue was to create a bubble chart with several series. e.g. Code: $this->DataSet->addPoints(array(0,0,0,0,0,0,0),"Probe1"); $this->DataSet->addPoints(array(0.1,0.2,0.3,0.4,0.5,0.6,0.7),"Probe1Weight"); $this->DataSet->addPoints(array(1,1,1,1,1,1,1),"Probe2"); $this->DataSet->addPoints(array(0.1,0.2,0.3,0.4,0.5,0.6,0.7),"Probe2Weight"); $this->DataSet->addPoints(array(2,2,2,2,2,2,2),"Probe3"); $this->DataSet->addPoints(array(0.1,0.2,0.3,0.4,0.5,0.6,0.7),"Probe3Weight"); $this->DataSet->addPoints(array(3,3,3,3,3,3,3),"Probe4"); $this->DataSet->addPoints(array(0.1,0.2,0.3,0.4,0.5,0.6,0.7),"Probe4Weight"); $this->DataSet->addPoints(array(4,4,4,4,4,4,4),"Probe5"); $this->DataSet->addPoints(array(0.1,0.2,0.3,0.4,0.5,0.6,0.7),"Probe5Weight"); $this->DataSet->addPoints(array(5,5,5,5,5,5,5),"Probe6"); $this->DataSet->addPoints(array(0.1,0.2,0.3,0.4,0.5,0.6,0.7),"Probe6Weight"); $this->DataSet->addPoints(array(6,6,6,6,6,6,6),"Probe7"); $this->DataSet->addPoints(array(0.1,0.2,0.3,0.4,0.5,0.6,0.7),"Probe7Weight"); $this->DataSet->addPoints(array(7,7,7,7,7,7,7),"Probe8"); $this->DataSet->addPoints(array(0.1,0.2,0.3,0.4,0.5,0.6,0.7),"Probe8Weight");
1 serie for the abscissa + 8 mentioned series In this case i'll get an error: Code: E_NOTICE [8] Undefined offset: 8 in line 102 of file /htdocs/develop3/pub/berichtsplugins/pChart_v2/class/pBubble.class.php Around line 102, the pBubble::resetSeriesColors() method is defined. resetSeriesColors will be called from drawBubbleChart() method. resetSeriesColors calls at the beginning Code: $Palette = $this->pDataObject->getPalette(); and gets an array with 8 items (defined in pData class) (containing rgb code + alpha). Code: var $Palette = array("0"=>array("R"=>188,"G"=>224,"B"=>46,"Alpha"=>100), "1"=>array("R"=>224,"G"=>100,"B"=>46,"Alpha"=>100), "2"=>array("R"=>224,"G"=>214,"B"=>46,"Alpha"=>100), "3"=>array("R"=>46,"G"=>151,"B"=>224,"Alpha"=>100), "4"=>array("R"=>176,"G"=>46,"B"=>224,"Alpha"=>100), "5"=>array("R"=>224,"G"=>46,"B"=>117,"Alpha"=>100), "6"=>array("R"=>92,"G"=>224,"B"=>46,"Alpha"=>100), "7"=>array("R"=>224,"G"=>176,"B"=>46,"Alpha"=>100)); In the following lines the method runs through all declared series and overwrites whose rgb codes: Code: $this->pDataObject->Data["Series"][$SerieName]["Color"]["R"] = $Palette[$ID]["R"]; ... For the ninth series, the loop will access on $Palette[8]["R"] which will throw above-mentioned error. To add a new color via: Code: $this->DataSet->setPalette(array(8=>"Probe8"), array("R"=>220,"G"=>220,"B"=>220,"Alpha"=>50)); will not solve the problem, because the palette of the pData class will never be extended, because of following lines (pData::setPalette): Code: /* 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; } }
Quick'n'dirty fix would be to remove Code: $this->resetSeriesColors(); in line 135 (pBubble::drawBubbleChart) Sry for "german" english. Best regards.
|