jpgraph - SetCenter不起作用

时间:2015-01-02 16:23:49

标签: php jpgraph

大家新年快乐,

今天我下载了jpgrap并查看了这些示例。 我想创建一个饼图,左侧有一个图例,右侧有图表。

在网络上,我发现SetCenter功能应该移动图形,但它不起作用。图表始终显示在中心。

这是我的代码

<?php
require_once ('jpgraph/src/jpgraph.php');
require_once ('jpgraph/src/jpgraph_pie.php');

$strSql = "SELECT
                YEAR(Datum) AS JAHR
            FROM kart_rundenzeiten_kopf
            WHERE
                BahnID = '".$_SESSION['KART_STATISTIK_BAHN_ID']."'
            GROUP BY YEAR(Datum)
            ORDER BY JAHR DESC";
$result = mysql_query($strSql) or die("MySQL-Error: ".mysql_error());

$strLR = 'L';

while ($row = mysql_fetch_assoc($result))
{
    $intJahr = $row['JAHR'];

    switch( $strLR )
    {
        case 'L':
            {
                $strFloat = 'left';
                $strLR = 'R';
            } break;

        case 'R':
            {
                $strFloat = 'right';
                $strLR = 'L';
            } break;
    }
?>
    <div style="display:block; float:<?php echo $strFloat; ?>; width:49.5%;">
        <div class="div_hauptbereich" style="display:block;">
            <?php
            $strSql2 = "SELECT
                            FLOOR( (A.Rundenzeit / 1000) ) AS RUNDENZEIT,
                            COUNT(*) AS ANZAHL
                        FROM kart_rundenzeiten_posten A
                        LEFT JOIN kart_rundenzeiten_kopf B ON A.BahnID = B.BahnID AND A.RundenID = B.KopfID
                        WHERE
                            B.BahnID = '".$_SESSION['KART_STATISTIK_BAHN_ID']."'
                            AND B.Strecke = '".$_SESSION['KART_STATISTIK_STRECKEN_ID']."'
                            AND YEAR(B.Datum) = '".$intJahr."'
                        GROUP BY FLOOR( (A.Rundenzeit / 1000) )
                        ORDER BY RUNDENZEIT";
            $result2 = mysql_query($strSql2) or die("MySQL-Error: ".mysql_error());

            $arrayData = array();
            $arrayLegende = array();

            while($row2 = mysql_fetch_assoc($result2))
            {
                $strZeit = Sekunden_In_Zeit( $row2['RUNDENZEIT'] );
                $intAnzahl = $row2['ANZAHL'];

                array_push( $arrayData, $intAnzahl );
                array_push( $arrayLegende, $strZeit.' - '.$intAnzahl.'x' );
            }

            print_r($arrayData);

            unlink("programme/kart/statistiken/charts/alle_zeiten_".$intJahr."_pie.png");

            $graph = new PieGraph(670,400,"auto");
            $graph->SetShadow();

            $graph->title->Set($intJahr);
            $graph->title->SetFont(FF_ARIAL,FS_BOLD,20);
            $graph->title->SetColor('#4444FF');

            $p1 = new PiePlot($arrayData);

            $p1->SetSize(0.3);
            $p1->SetCenter(0.35,0.5);

            $p1->value->SetFont(FF_FONT1);
            $p1->value->SetColor("black");

            $p1->SetLabelType(PIE_VALUE_ABS);

            $p1->value->SetFormat("%d");
            $p1->value->HideZero();
            $p1->value->Show();

            $p1->SetLegends( $arrayLegende );
            $graph->legend->Pos(0.73,0.05);
            $graph->legend->SetColumns(2);

            $graph->Add($p1);
            $graph->Stroke("programme/kart/statistiken/charts/alle_zeiten_".$intJahr."_pie.png");
            ?>

            <img src="programme/kart/statistiken/charts/alle_zeiten_<?php echo $intJahr; ?>_pie.png">
        </div>
    </div>
<?php
}
?>

我有什么设置我必须在PHP中更改? 我正在使用Firefox 34,但我也尝试使用IE 11。

我希望有人可以帮我解决这个问题。

0 个答案:

没有答案