1

我正在尝试使用 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");

结果是一个没有任何文字的图表。感谢您的帮助。

4

1 回答 1

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);

我希望这就是全部。祝你好运

于 2015-06-16T01:00:57.053 回答