Witam, wszystkich!

Na podstawie przykładowych wykresów staram się stworzyć swój. Nie mogę sobie poradzić z jakimś błędem odnośnie wczytywania danych z pliku tekstowego.
Mój kod:

  1. /* CAT:Area Chart */
  2.  
  3. /* pChart library inclusions */
  4. include("../class/pData.class.php");
  5. include("../class/pDraw.class.php");
  6. include("../class/pImage.class.php");
  7.  
  8. /* Create and populate the pData object */
  9. $MyData = new pData();
  10.  
  11. $nazwa_pliku = "xy.txt";
  12. if (is_readable($nazwa_pliku))
  13. {
  14. if ($plik = fopen($nazwa_pliku, "r"))
  15. {
  16. $dane = file($nazwa_pliku);
  17. if ($dane === FALSE) echo "Odczyt danych z pliku nie powiódł się...";
  18. else
  19. for($i=0; $i<= 1000; $i++)
  20. {
  21. $MyData->addPoints($dane[$i],"Inbound");
  22. }
  23. fclose($plik);
  24. } else echo "Nie mogę nawiązać połączenia z plikiem...";
  25. } else echo "Z pliku nie można odczytać informacji lub nie istnieje...";
  26.  
  27. /* Create the pChart object */
  28. $myPicture = new pImage(700,230,$MyData);
  29.  
  30. /* Turn of Antialiasing */
  31. $myPicture->Antialias = FALSE;
  32.  
  33. /* Add a border to the picture */
  34. $myPicture->drawRectangle(0,0,699,229,array("R"=>0,"G"=>0,"B"=>0));
  35.  
  36. /* Write the chart title */
  37. $myPicture->setFontProperties(array("FontName"=>"../fonts/Forgotte.ttf","FontSize"=>11));
  38. $myPicture->drawText(150,35,"Average temperature",array("FontSize"=>20,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE));
  39.  
  40. /* Set the default font */
  41. $myPicture->setFontProperties(array("FontName"=>"../fonts/pf_arma_five.ttf","FontSize"=>6));
  42.  
  43. /* Define the chart area */
  44. $myPicture->setGraphArea(60,40,650,200);
  45.  
  46. /* Draw the scale */
  47. $scaleSettings = array("XMargin"=>10,"YMargin"=>10,"Floating"=>TRUE,"GridR"=>200,"GridG"=>200,"GridB"=>200,"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE);
  48. $myPicture->drawScale($scaleSettings);
  49.  
  50. /* Write the chart legend */
  51. $myPicture->drawLegend(540,20,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL));
  52.  
  53. /* Turn on Antialiasing */
  54. $myPicture->Antialias = TRUE;
  55.  
  56. /* Draw the area chart */
  57. $myPicture->drawAreaChart();
  58.  
  59. /* Render the picture (choose the best way) */
  60. $myPicture->autoOutput("pictures/example.drawAreaChart.simple.png");


a to oryginalny kod powyższego wykresu:

  1. /* CAT:Area Chart */
  2.  
  3. /* pChart library inclusions */
  4. include("../class/pData.class.php");
  5. include("../class/pDraw.class.php");
  6. include("../class/pImage.class.php");
  7.  
  8. /* Create and populate the pData object */
  9. $MyData = new pData();
  10. $MyData->addPoints(array(4,2,10,12,8,3),"Probe 1");
  11. $MyData->addPoints(array(3,12,15,8,5,5),"Probe 2");
  12. $MyData->addPoints(array(2,7,5,18,15,22),"Probe 3");
  13. $MyData->setSerieTicks("Probe 2",4);
  14. $MyData->setAxisName(0,"Temperatures");
  15. $MyData->addPoints(array("Jan","Feb","Mar","Apr","May","Jun"),"Labels");
  16. $MyData->setSerieDescription("Labels","Months");
  17. $MyData->setAbscissa("Labels");
  18.  
  19. /* Create the pChart object */
  20. $myPicture = new pImage(700,230,$MyData);
  21.  
  22. /* Turn of Antialiasing */
  23. $myPicture->Antialias = FALSE;
  24.  
  25. /* Add a border to the picture */
  26. $myPicture->drawRectangle(0,0,699,229,array("R"=>0,"G"=>0,"B"=>0));
  27.  
  28. /* Write the chart title */
  29. $myPicture->setFontProperties(array("FontName"=>"../fonts/Forgotte.ttf","FontSize"=>11));
  30. $myPicture->drawText(150,35,"Average temperature",array("FontSize"=>20,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE));
  31.  
  32. /* Set the default font */
  33. $myPicture->setFontProperties(array("FontName"=>"../fonts/pf_arma_five.ttf","FontSize"=>6));
  34.  
  35. /* Define the chart area */
  36. $myPicture->setGraphArea(60,40,650,200);
  37.  
  38. /* Draw the scale */
  39. $scaleSettings = array("XMargin"=>10,"YMargin"=>10,"Floating"=>TRUE,"GridR"=>200,"GridG"=>200,"GridB"=>200,"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE);
  40. $myPicture->drawScale($scaleSettings);
  41.  
  42. /* Write the chart legend */
  43. $myPicture->drawLegend(540,20,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL));
  44.  
  45. /* Turn on Antialiasing */
  46. $myPicture->Antialias = TRUE;
  47.  
  48. /* Draw the area chart */
  49. $myPicture->drawAreaChart();
  50.  
  51. /* Render the picture (choose the best way) */
  52. $myPicture->autoOutput("pictures/example.drawAreaChart.simple.png");


fragment zawartości pliku xy.txt wygląda tak:
Kod
-4.99
-4.98
-4.97
-4.96
-4.95
-4.94
-4.93
-4.92
-4.91
-4.9
-4.89
-4.88
-4.87
-4.86
-4.85
-4.84
-4.83
-4.82
-4.81
-4.8
-4.79
-4.78
-4.77
-4.76
-4.75
-4.74
-4.73
-4.72
-4.71
-4.7
-4.69
-4.68
-4.67


po odpaleniu skryput na stonie wyświetlony zostaje komunikat o tym że, obrek nie może być wyświetlony poniważ zawiera błąd. I tyle... pomożecie? smile.gif