圖形無法顯示在PHPLOT上
<p>如果可能的話,我想在PHPLOT上尋求幫助。圖表在使用虛擬資料時正常顯示,但當我呼叫$words陣列時,圖表不顯示。</p>
<p>圖表代碼:</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>如果我取消註解<code>//$words = ProcessaPdf::geraArrayPalavrasChave();</code>這一行,圖表就會失敗</p>
<p>所以我不能用$word取代$data</p>
<p>傳回$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>我嘗試從$words陣列產生圖表</p>
<p>更新</p>
<p><code>$words = ProcessaPdf::geraArrayPalavrasChave();</code></p>
<p>返回陣列:</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>