(Yes, Sourceforge forum formatting is trouble. They recently switched from
markdown to bbcode, without much notice, and broke the previous posts'
formatting... and with bbcode they removed the "preview" button which was
really helpful. But it's OK, I can read it, more or less.)
Your data array is not formed correctly and I'm not sure why it works in any
case. It would help if you had a way to print_r the array (and then exit
without drawing anything) so you could check on it. Basically, $adat must be
an array, with numeric indexes starting at 0. When you filter your data, your
are skipping values but still incrementing $i so your adat array indexes do
not start at 0. Also, each element of $adat needs to be an array. You are
setting $adat_ to a string, then setting sub-elements. I don't think this is
what you want._
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you for fast help. I always check with var_dump(), but I did not
realize, that indexes caused problem. So that is why graph worked with hole
file, or with only first rows. I corrected the array and now it is working
fine. Thanks again!
It turns out that this requirement that the data array use "0-based sequential
integer indexing" isn't documented. (It is documented for many other functions
that take arrays, such as SetDataColors.) So you've helped by pointing out
something I need to fix in the documentation.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I have a txt file, and I prepare an array from it. I like to draw a graph per
a day, so I filter datas and this is the problem.
1, If I use the hole file, without IF statement, the graph works.
2, If I filter, and datas are from the beginning of the file, the graph works.
$datum = mktime(0, 0, 0, 02, 11, 2010);
3, If I filter, and datas are not from the beginning of the file, the graph
does not work.
$datum = mktime(0, 0, 0, 02, 12, 2010); OR $datum = mktime(0, 0, 0, 02, 13,
2010);
Error message:
Warning: array_values() : The argument should be an array in .../phplot.php on
line 2219
What could be the problem? The array is the SAME! Thank you in advance.
** EXAMPLE.PHP *****
$datum && (integer)$item < $datum+86400) { $adat = date("H:i", (integer)$item); $adat = (integer)$item; $adat = (integer)$item; $adat = (integer)$item; } $i++; } require '../phplot/phplot.php'; $plot = new PHPlot(800,600); $plot->SetDataValues($adat); $plot->SetDataType('text-data'); $plot->SetTitle("Stat"); $plot->SetXTitle('time'); $plot->SetXDataLabelAngle(90); $plot->SetLegend(array('memory1', 'memory2', 'mails')); $plot->SetImageBorderType('plain'); $plot->DrawGraph(); fclose($fp); ?>** MEM.TXT ****
1265899417, 994048, 10868, 0
1265899419, 994024, 12888, 2
1265899421, 994024, 12888, 4
1265899467, 817268, 10872, 0
1265899469, 818088, 16632, 5
1265899471, 818420, 18345, 10
1265899473, 818172, 18989, 12
1265899475, 818776, 19234, 14
1265899477, 818716, 20456, 16
1265899479, 818888, 20897, 18
1265899481, 819280, 20983, 20
1265900317, 839792, 10868, 0
1265900319, 839808, 12888, 2
1265900321, 839976, 12888, 4
1265900323, 840156, 13212, 6
1265900325, 840280, 13897, 8
1265900327, 840472, 14034, 10
1265900329, 840584, 14567, 12
1265900331, 840720, 14923, 14
1265929071, 911460, 10868, 0
1265929074, 911636, 12888, 2
1265929076, 912356, 12888, 4
1265929078, 912500, 16632, 6
1265929080, 912632, 16990, 8
1265929082, 911680, 16990, 10
1265929084, 911516, 16990, 12
1265929086, 911820, 16999, 14
1265974165, 913156, 10868, 0
1265974167, 913652, 12888, 2
1265974169, 913392, 12888, 4
1265974171, 913032, 13023, 6
1265974173, 913020, 13020, 8
1265974175, 913080, 13090, 10
1265974177, 913328, 13650, 12
1265974179, 912764, 13650, 14
1265974220, 911468, 10868, 0
1265974222, 911952, 12888, 2
1265974224, 911952, 12888, 4
1265974383, 915528, 10868, 0
1265974385, 915832, 12888, 2
1265974387, 916452, 12888, 4
1265974469, 912488, 10868, 0
1265974471, 912692, 12888, 2
1265974473, 914028, 12888, 4
1265974521, 917884, 10868, 0
1265974523, 918616, 12888, 2
1265974525, 917872, 12888, 4
1266065227, 858672, 10868, 0
1266065229, 859772, 12888, 2
1266065231, 859840, 12888, 4
1266227541, 877592, 10868, 0
1266227543, 878204, 12888, 2
1266227545, 879108, 12888, 4
1266310046, 885912, 10868, 0
1266310049, 886516, 12888, 2
1266310051, 887624, 12888, 4
1266320381, 863480, 10868, 0
1266320383, 864576, 12888, 2
1266320385, 864588, 12888, 4
1266320560, 845352, 10872, 0
1266320565, 847196, 16632, 5
1266329931, 908252, 16656, 0
1266329936, 907936, 16660, 5
1266389561, 858968, 10884, 0
1266389566, 862732, 16636, 5
1266406427, 724060, 10880, 0
1266406432, 727480, 16644, 5
1266758518, 749980, 10888, 0
1266758523, 755168, 16644, 5
Sorry, I forget codify text, try again:
(Yes, Sourceforge forum formatting is trouble. They recently switched from
markdown to bbcode, without much notice, and broke the previous posts'
formatting... and with bbcode they removed the "preview" button which was
really helpful. But it's OK, I can read it, more or less.)
Your data array is not formed correctly and I'm not sure why it works in any
case. It would help if you had a way to print_r the array (and then exit
without drawing anything) so you could check on it. Basically, $adat must be
an array, with numeric indexes starting at 0. When you filter your data, your
are skipping values but still incrementing $i so your adat array indexes do
not start at 0. Also, each element of $adat needs to be an array. You are
setting $adat_ to a string, then setting sub-elements. I don't think this is
what you want._
Thank you for fast help. I always check with var_dump(), but I did not
realize, that indexes caused problem. So that is why graph worked with hole
file, or with only first rows. I corrected the array and now it is working
fine. Thanks again!
$fp = @fopen('mem.txt', r);
$tomb = file('mem.txt');
$adat = array();
$datum = mktime(0, 0, 0, 02, 12, 2010);
foreach ($tomb as $sor) {
$item = explode(", ", $sor);
if ((integer)$item > $datum && (integer)$item < $datum+86400) {
$row = array();
$row = date("H:i", (integer) $item);
$row = (integer)$item;
$row = (integer)$item;
$row = (integer)$item;
array_push($adat, $row);
}
}
var_dump($adat);
fclose($fp);
It turns out that this requirement that the data array use "0-based sequential
integer indexing" isn't documented. (It is documented for many other functions
that take arrays, such as SetDataColors.) So you've helped by pointing out
something I need to fix in the documentation.