За последние 24 часа нас посетили 22839 программистов и 1262 робота. Сейчас ищут 697 программистов ...

Построение графика в php с помощью библиотеки pChart

Тема в разделе "Прочие вопросы по PHP", создана пользователем mmmxx, 4 фев 2018.

  1. mmmxx

    mmmxx Новичок

    С нами с:
    4 фев 2018
    Сообщения:
    1
    Симпатии:
    0
    PHP:
    1. <?php
    2. /* Include the pData class */
    3. include 'pChart/pData.class';
    4. include 'pChart/pCache.class';
    5. include 'pChart/pChart.class';
    6.  
    7. //создаем объект данных
    8. $myData = new pData();
    9.  
    10. /* Коннектимся к MySQL базе данных */
    11. $db = mysql_connect("host", "smct", "*******");
    12. if ( $db == "" ) { echo " DB Connection error...\r\n"; exit(); }
    13.  
    14. mysql_select_db("dle",$db);
    15.  
    16. $Requete = "SELECT `timeStamp`,`quantity` FROM `table` ";
    17. $result  = mysql_query($Requete,$db);
    18. while ($row = mysql_fetch_array($result))
    19. {
    20.   $DataSet->AddPoint($row["timeStamp"],"timeStamp");
    21.   $DataSet->AddPoint($row["quantity"],"quantity");  
    22. }
    23.  
    24.  
    25.  
    26. $myData->SetAbsciseLabelSerie("timeStamp");
    27.  
    28. $myData->AddSerie("quantity");
    29.  
    30. $myData->SetSerieName(
    31. mb_convert_encoding("quantity",'utf-8','windows-1251'),
    32. "quantity");
    33.  
    34. $graph = new pChart(1000,500);
    35. $graph->setFontProperties("Intro-Bold.ttf",10);
    36.  
    37. $graph->setGraphArea(85,30,950,400);
    38.  
    39. $graph->drawFilledRoundedRectangle(7,7,993,493,5,240,
    40. 240,240);
    41.  
    42. $graph->drawRoundedRectangle(5,5,995,495,5,230,
    43. 230,230);
    44.  
    45. $graph->drawGraphArea(255,255,255,TRUE);
    46.  
    47. $graph->drawScale($myData->GetData(),
    48. $myData->GetDataDescription(),
    49. SCALE_NORMAL,150,150,150,true,0,2);
    50.  
    51. $graph->drawGrid(4,TRUE,230,230,230,50);
    52.  
    53. $graph->drawLineGraph($myData->GetData(),
    54. $myData->GetDataDescription());
    55. $graph->drawPlotGraph($myData->GetData(),
    56. $myData->GetDataDescription(),3,2,255,255,255);
    57.  
    58. $graph->setFontProperties("Intro-Bold.ttf",10);
    59. $graph->drawTextBox(870,450,990,460,"Powered By pChart",
    60. 0,250,250,250,ALIGN_CENTER,TRUE,-1,-1,-1,30);
    61. $graph->drawTextBox(805,470,990,480,"http://pchart.sourceforge.net",
    62. 0,250,250,250,ALIGN_CENTER,TRUE,-1,-1,-1,30);
    63. $graph->drawTextBox(15,450,140,460,"Developed By kv4nt",
    64. 0,250,250,250,ALIGN_CENTER,TRUE,-1,-1,-1,30);
    65. $graph->drawTextBox(10,470,140,480,"http://www.piarcom.com",
    66. 0,250,250,250,ALIGN_CENTER,TRUE,-1,-1,-1,30);
    67. $graph->drawLegend(90,35,$myData->GetDataDescription(),255,255,255);
    68.  
    69. $graph->setFontProperties("Intro-Bold.ttf",10);
    70. $graph->drawTitle(480,22,
    71. mb_convert_encoding("График",
    72. 'utf-8','windows-1251'),
    73. 50,50,50,-1,-1,true);
    74.  
    75. $graph->Stroke();
    76. /**
    77. * @return array
    78. */
    79.  
    80. ?>
    upload_2018-2-4_19-22-48.png

    Пытаюсь построить график по данным из БД, не пойму почему не строится линия графика. Помогите пожлста.