💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
>[success] ### 以线性图为例代码分析 1.引入类库 require_once "/src/jpgraph.php"; //核心文件 require_once "/src/jpgraph_line.php"; //线性图文件 2.引入数据 $data=array(1=>1,...); 3.得到Graph对象(创建画布) $graph=new Graph(w,h); //w-画布长;h-画布宽 4.设置X和Y轴样式及Y轴的最大值最小值 $graph->SetScale($aAxisType,$min,$max);//如:$aAxisType='textint';则x坐标样式为text,y坐标样式为int 5.设置图像样式,如加入阴影 $graph->SetShadow(); 6.设置图像边界范围 $graph->img->setMargin($up,$right,$down,$left);//顺时针填充值 7.设置标题 $graph->title->Set($title);//中文参见问题解决 8.得到曲线实例(插入数据) $linePlot=new LinePlot($data); 9.将曲线加入到图像中 $graph->Add($linePlot); 10.设置曲线的颜色 $linePlot->setColor($color);//代码位置参见问题解决 11.设置坐标轴名称 $graph->xaxis->title->Set($xName); //X坐标轴名称 $graph->yaxis->title->Set($yName);//y坐标轴名称 12.设置曲线的图例 $linePlot->SetLegend($legend);//中文参见问题解决 13.设置图例样式 $graph->legend->setlayout(LEGEND_HOR); 14设置图例位置 $graph->legend->Pos(0.45,0.9,"center","bottom"); 15输出 $graph->Stroke();//将图像输出到浏览器 $graph->Stroke($path);//如:$graph->Stroke('./test.png');保存到当前目录下并命名test