支持中文配置
1、修改jpgraph_ttf.inc.php
搜索CHINESE_TTF_FONT选项,修改常量的值是支持中文的字体
define('CHINESE_TTF_FONT','SIMYOU.TTF');
2.支持图例中文
修改jpgraph_legend.inc.php
public $font_family=FF_CHINESE,$font_style=FS_NORMAL,$font_size=8; // old. 12
3.test.php
$graph->title->SetFont(FF_CHINESE);
$test.php
<?php
require_once '../src/jpgraph.php';
require_once '../src/jpgraph_line.php';
$graph = new Graph(600, 400);
/**
* lin直线
* text文本
* int整数
* long对数
* textint
*/
$aAxisType = 'textint';
$graph->SetScale($aAxisType);
//设置统计图的标题
$graph->title->SetFont(FF_CHINESE);
$graph->title->Set('慕课网');
$data = array(0 => 10, 1 => 20, 2 => 30, 3 => 40, 4 => 50, 5 => 12, 6 => 38, 7 => 55, 8 => 100,
9 => 120, 10 => 30, 11 => 54
);
$linePlot = new LinePlot($data);
//设置图例
$linePlot->SetLegend('测试中文');
//将统计图添加到画布上
$graph->Add($linePlot);
//设置统计图的颜色 一定要在添加到画布之后再设置
$linePlot->SetColor('red');
$graph->Stroke();
Paste_Image.png