コードが見えずくなっておりました、すみません。再投稿です。
やりたいことjpgraphのライブラリで縦棒グラフを作成したい。
1.jpgraphのライブラリをcmd を使って下記のコマンドで追加しました。
compoer require jpgraph/jpgraph
2.下記のプログラムを実行すると、次のエラーになります。
<?php // ダウンロードした以下のファイルを読み込む require 'vendor/autoload.php'; require('vendor/jpgraph/jpgraph/lib/jpgraph/src/jpgraph.php'); require ('vendor/jpgraph/jpgraph/lib/jpgraph/src/jpgraph_bar.php'); // 縦軸のデータ $x_data = array(1,5,10); // グラフの生成 $graph = new Graph(400, 300); $graph->SetScale('textlin'); $graph->SetMarginColor('white'); // タイトル $graph->title->Set('test_graph'); // グラフ表示 $bar = new BarPlot($x_data); $bar->value->Show(); $graph->Add($bar); $graph->Stroke(); ?>
次のエラー
Fatal error: Uncaught TypeError: JpGraphException::defaultHandler(): Argument #1 ($exception) must be of type Exception, TypeError given in C:\xampp\htdocs\mysql_php\vendor\jpgraph\jpgraph\lib\jpgraph\src\jpgraph_errhandler.inc.php:158 Stack trace: #0 [internal function]: JpGraphException::defaultHandler(Object(TypeError)) #1 {main} thrown in C:\xampp\htdocs\mysql_php\vendor\jpgraph\jpgraph\lib\jpgraph\src\jpgraph_errhandler.inc.php on line 158
エラーでやったこと
php.iniでextention = gd をコメントアウト
jpgraph_errhandler.inc.php の158行目の static public function defaultHandler(Exception $exception)をstatic public function defaultHandler($exception)に変更。https://groups.google.com/g/jpgraph/c/BdNobeWfoMk?pli=1を参考にしました。
上記を行いましたが、結果としては、エラーが同じです。他に解決策はございますでしょうか。
回答1件
あなたの回答
tips
プレビュー