我正在尝试使用php和pChart框架绘制图表。问题在于没有绘制图表文本。
include "pChart2.1.1/class/pData.class.php";
include "pChart2.1.1/class/pDraw.class.php";
include "pChart2.1.1/class/pImage.class.php";
$myData = new pData();
## DEFINITION OF SERIES AND X AXIS... ##
$myData->setAbscissa("Absissa");
$myData->setAxisPosition(0, AXIS_POSITION_LEFT);
$myData->setAxisName(0, "1st axis");
$myData->setAxisUnit(0, "");
$myPicture = new pImage(1024, 600, $myData);
$Settings = array("R" => 255, "G" => 255, "B" => 255, "Dash" => 1, "DashR" => 275, "DashG" => 275, "DashB" => 275);
$myPicture->drawFilledRectangle(0, 0, 1024, 600, $Settings);
$myPicture->drawRectangle(0, 0, 1023, 599, array("R" => 0, "G" => 0, "B" => 0));
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 50, "G" => 50, "B" => 50, "Alpha" => 20));
$myPicture->setFontProperties(array("FontName" => "fonts/Bedizen.ttf", "FontSize" => 40));
$TextSettings = array("Align" => TEXT_ALIGN_TOPMIDDLE, "R" => 255, "G" => 255, "B" => 255);
$myPicture->drawText(512, 25, "Abertura Geral", $TextSettings);
$myPicture->setShadow(TRUE);
$myPicture->setGraphArea(50, 50, 999, 560);
$myPicture->setFontProperties(array("R" => 0, "G" => 0, "B" => 0, "FontName" => "fonts/pf_arma_five.ttf", "FontSize" => 6));
$Settings = array("Pos" => SCALE_POS_LEFTRIGHT
, "Mode" => SCALE_MODE_FLOATING
, "LabelingMethod" => LABELING_ALL
, "GridR" => 255, "GridG" => 255, "GridB" => 255, "GridAlpha" => 50, "TickR" => 0, "TickG" => 0, "TickB" => 0, "TickAlpha" => 50, "LabelRotation" => 0, "CycleBackground" => 1, "DrawXLines" => 1, "DrawSubTicks" => 1, "SubTickR" => 255, "SubTickG" => 0, "SubTickB" => 0, "SubTickAlpha" => 50, "DrawYLines" => ALL);
$myPicture->drawScale($Settings);
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 50, "G" => 50, "B" => 50, "Alpha" => 10));
$Config = "";
$myPicture->drawLineChart($Config);
$Config = array("FontR" => 0, "FontG" => 0, "FontB" => 0, "FontName" => "fonts/pf_arma_five.ttf", "FontSize" => 6, "Margin" => 6, "Alpha" => 30, "BoxSize" => 5, "Style" => LEGEND_NOBORDER,
"Mode" => LEGEND_HORIZONTAL);
$myPicture->drawLegend(938, 16, $Config);
$myPicture->render("/tmp/t2.png");
结果是没有任何文字的图表。 谢谢你的帮助。
答案 0 :(得分:0)
我认为这是你的问题
$TextSettings = array("Align" => TEXT_ALIGN_TOPMIDDLE, "R" => 255, "G" => 255, "B" => 255);
文字是白色的,与你应该更改此行的背景相同:
$TextSettings = array("Align" => TEXT_ALIGN_TOPMIDDLE, "R" => 0, "G" => 0, "B" => 0);
我希望就是这样。祝你好运