Home  >  Q&A  >  body text

Graphics cannot be displayed on PHPLOT

<p>I would like to seek help on PHPLOT if possible. The chart displays fine when using dummy data, but when I call the $words array, the chart does not display.</p> <p>Chart code:</p> <pre class="brush:php;toolbar:false;"><?php include_once ("class/ProcessaPdf.class.php"); require_once 'lib/phplot-5.5.0/phplot.php'; //$words = ProcessaPdf::geraArrayPalavrasChave(); $plot = new PHPlot(640, 480); $data = array( array('1940', 6.2), array('1950', 6.2), array('1960', 6.3), array('1970', 5.8), ); $plot->SetTitle('Grafico da analise de palavras-chave encontradas'); $plot->SetPlotType("bars"); $plot->SetXLabel("Palavras"); $plot->SetYLabel("Frequencia"); $plot->SetXLabelFontSize(2); $plot->SetAxisFontSize(2); $plot->SetDataValues($data); $plot->SetYDataLabelPos('plotin'); $plot->DrawGraph(); ?></pre> <p>If I uncomment the line <code>//$words = ProcessaPdf::geraArrayPalavrasChave();</code> the chart fails</p> <p>So I can’t replace $data with $word</p> <p>Function that returns $words: </p> <pre class="brush:php;toolbar:false;">static function geraArrayPalavrasChave(){ $p_chaves = file("./lib/palavras_chave.txt", FILE_TEXT | FILE_IGNORE_NEW_LINES); // Initialize and load PDF Parser library $parser = new SmalotPdfParserParser(); // Source PDF file to extract text $file = 'lib/projeto.pdf'; // Parse pdf file using Parser library $pdf = $parser->parseFile($file); // Extract text from PDF $text = $pdf->getText(); for($i=0; $i<count($p_chaves); $i ){ if(substr_count(' '.$text.' ', ' '.$p_chaves[$i].' ') != ''){ $dados[$i][] = $p_chaves[$i]; $dados[$i][] = substr_count(mb_strtoupper(' '.$text.' '), mb_strtoupper(' '.$p_chaves[$i].' ')); } } for($i=0; $i<count($dados); $i ){ $key[] = $i; } $arrayPalavras = array_combine($key, $dados); return $arrayPalavras; }</pre> <p>I tried to generate a chart from the $words array</p> <p>Update</p> <p><code>$words = ProcessaPdf::geraArrayPalavrasChave();</code></p> <p>Return array: </p> <pre class="brush:php;toolbar:false;">Array ( [0] => Array ( [0] => inovações [1] => 3 ) [1] => Array ( [0] => tecnologia da informação [1] => 2 ) [2] => Array ( [0] => intelectuais [1] => 4 ) [3] => Array ( [0] => patente [1] => 5 ) )</pre> <p><br /></p>
P粉211273535P粉211273535448 days ago543

reply all(2)I'll reply

  • P粉635509719

    P粉6355097192023-08-21 20:06:52

    I solved this problem. I updated the pdfparser library in composer and then updated autoload. The problem is not in phplot, but in pdfparser.

    reply
    0
  • Cancelreply