OK, now to the undefined index error problem.
Currently, if you set text for an annotation such..
$label->setText("something\nsomethingelse");
The text will be processed through
Code: Select all
public function multiLineTextWidth($s) {
$result = new MultiLine();
// Note our use of ===. Simply == would not work as expected
// because the position of 'a' was the 0th (first) character.
$i = strpos($s, "\n"); //Language::getString("LineSeparator"));
if ($i === FALSE) {
$result->count = 1;
$result->width = $this->graphics3D->textWidth($s);
} else {
$tmpResult = 0;
$r = new CalcStringResults();
while ($i !== false) {
$r = $this->calcString($r, substr($s,0, $i + 1));
$tmpResult = $r->tmpResult;
$s = substr($s,$i + 1);
$i = strpos($s, "\n"); //Language::getString("LineSeparator"));
}
$result->count = $r->numLines;
$result->width = $r->tmpResult;
if (strlen($s) != 0) {
$result->count++;
$result->width = max($tmpResult, $this->graphics3D->textWidth($s));
}
}
return $result;
}
in Chart.php which divides it up by the "\n" for a count and calculates the width by string length for the default rectangle width based on text length, etc.
That exchange takes place on Annotation.php around line 348 in the drawText function.
Short applicable excerpt:
Code: Select all
$m = $this->chart->multiLineTextWidth($tmp);
$tmpW = $m->width-$tmpHeight;
$tmpN = $m->count;
$tmpH = $tmpN * $tmpHeight;
Note the $tmpN (count)
A little farther down in Annotation.php, you find this near line 417 (NOTE the markup and commenting out)..
Code: Select all
$s = Array();// Array of String
//$s = StringFormat::split($tmp, Language::getString("LineSeparator")); <<-----ORIGINAL CODE
$s = preg_split('/\\n/', $tmp ); <<-----MY CHANGE
for($t = 1; $t <= $tmpN; $t++)
{
$g->textOut($x, $y + ($t * $tmpHeight),0, $s[$t - 1]);
}
What was occurring is that there was an accurate count of string elements split by "\n" from the first return from Chart.php and then the string was subjected to this code at StringFormat.php around line 52...
Code: Select all
public static function split($in, $ch ){
$tmp= Array();
$pos=false;
do {
$pos = strpos($in,$ch);
if ($pos != false) {
$s = substr($in,0,$pos);
$tmp[]=$s;
$in = substr($in,0,$pos+1);
}
} while ($pos != false);
if (strlen($in) > 0) {
$tmp[]=$in;
}
//$result = new String[$this->tmp->size()];
return /*str_split(*/$tmp/*)*/;
}
That code has a problem returning the array it is supposed to return with a "\n" delimiter. Ergo, this string "some text\nmore text" would be returned in a single element array rather than two. Then part of the code from Annotation.php..
Code: Select all
for($t = 1; $t <= $tmpN; $t++)
{
$g->textOut($x, $y + ($t * $tmpHeight),0, $s[$t - 1]);
}
Has this dilemma.. the count from the - public function multiLineTextWidth($s) { for that string is 2 but the array returned by StringFormat.php contains only one element with all the text minus the "\n". So at the end of the for on the count of 2 where the code seeks $s[$t - 1] $t =2 at that point, and key [1] does not exist.... hence the undefined index error.
Since I cannot see that StringFormat.php does anything but return the string as an array divided by "\n", I used preg_split above to solve.
NOTE: DOUBLE QUOTES FOR THE TEXT i.e., "text\nmore text" ARE A MUST, SINGLE QUOTES (apostrophes) WILL NOT WORK FOR THAT.