From 5191ab89ef4d052e80d405efa5d40a3927ca5441 Mon Sep 17 00:00:00 2001 From: lacatoire Date: Thu, 7 May 2026 10:57:05 +0200 Subject: [PATCH] img-status: replace JpGraph with inline SVG --- www/img-status-all.php | 69 +++++++++++++++-------------------------- www/img-status-lang.php | 69 ++++++++++++++++++++--------------------- 2 files changed, 59 insertions(+), 79 deletions(-) diff --git a/www/img-status-all.php b/www/img-status-all.php index 37eddac..9bb02a0 100644 --- a/www/img-status-all.php +++ b/www/img-status-all.php @@ -1,7 +1,4 @@ SetScale("textlin"); - -$graph->xaxis->SetLabelmargin(5); -$graph->xaxis->SetTickLabels($legend); - -$graph->ygrid->SetFill(true,'#EFEFEF@0.5','#BBCCFF@0.5'); - -// Add a drop shadow -$graph->SetShadow(); - -// Adjust the margin a bit to make more room for titles -$graph->img->SetMargin(50,30,35,40); - -// Create a bar pot -$bplot = new BarPlot($percent); -$graph->Add($bplot); - -// Adjust fill color -$bplot->SetFillColor([ '#9999CC', '#99CC99', '#CC9999' ]); - -$bplot->SetShadow(); -$bplot->value->Show(); -$bplot->value->SetFont(FF_FONT1,FS_NORMAL,10); -$bplot->value->SetFormat('%0.0f%%'); - -// Width -$bplot->SetWidth(0.6); - -// Setup the titles -$graph->title->Set("PHP Translation Status"); -$graph->xaxis->title->Set("Language"); -$graph->yaxis->title->Set("Files up to date (%)"); - -$graph->title->SetFont(FF_FONT1,FS_BOLD); -$graph->yaxis->title->SetFont(FF_FONT1,FS_NORMAL); -$graph->xaxis->title->SetFont(FF_FONT1,FS_NORMAL); - -// Display the graph -$graph->Stroke(); +$colors = ['#9999CC', '#99CC99', '#CC9999']; +$bw = 44; $gap = 18; $left = 50; $right = 24; +$top = 60; $plot_h = 200; $bottom = 38; +$width = max(600, $left + count($percent) * ($bw + $gap) - $gap + $right); +$height = $top + $plot_h + $bottom; +$base = $top + $plot_h; + +header('Content-Type: image/svg+xml; charset=utf-8'); +echo ''; +?> + + + PHP Translation Status + Files up to date per language + + + % + + + $p): $x = $left + $i * ($bw + $gap); $h = $plot_h * $p / 100; $by = $base - $h; $cx = $x + $bw / 2; ?> + : % + % + + + diff --git a/www/img-status-lang.php b/www/img-status-lang.php index ba54520..ddad490 100644 --- a/www/img-status-lang.php +++ b/www/img-status-lang.php @@ -1,9 +1,5 @@ SetShadow(); - - $graph->title->Set($title); - $graph->title->Align('left'); - $graph->title->SetFont(FF_FONT1,FS_BOLD); - - $graph->legend->Pos(0.02,0.18,"right","center"); - - $graph->subtitle->Set('(Total: '.$total_files_lang.' files)'); - $graph->subtitle->Align('left'); - $graph->subtitle->SetColor('darkred'); - - $t1 = new Text(date('m/d/Y')); - $t1->SetPos(522,294); - $t1->SetFont(FF_FONT1,FS_NORMAL); - $t1->Align("right", 'bottom'); - $t1->SetColor("black"); - $graph->AddText($t1); - - $p1 = new PiePlot3D($data); - $p1->SetSliceColors(array("#68d888", "#ff6347", "#dcdcdc", "#f4a460")); - if ($total_files_lang != $up_to_date) { - $p1->ExplodeAll(); + $colors = ['#61A9F3', '#F381B9', '#61E3A9', '#85ED82']; + + $W = 680; $H = 300; $cx = 140; $cy = 165; $ro = 110; $ri = 64; + + header('Content-Type: image/svg+xml; charset=utf-8'); + echo ''; + echo ''; + echo ''; + echo ''.htmlspecialchars($title).''; + echo '(Total: '.$total_files_lang.' files)'; + + $angle = -M_PI / 2; + foreach ($data as $i => $value) { + if ($value <= 0) continue; + $sweep = ($value / $total) * 2 * M_PI; + $end = $angle + $sweep; + $sx1 = $cx + $ro * cos($angle); $sy1 = $cy + $ro * sin($angle); + $ex1 = $cx + $ro * cos($end); $ey1 = $cy + $ro * sin($end); + $sx2 = $cx + $ri * cos($end); $sy2 = $cy + $ri * sin($end); + $ex2 = $cx + $ri * cos($angle); $ey2 = $cy + $ri * sin($angle); + $large = ($end - $angle) > M_PI ? 1 : 0; + $d = sprintf('M %.2f %.2f A %d %d 0 %d 1 %.2f %.2f L %.2f %.2f A %d %d 0 %d 0 %.2f %.2f Z', + $sx1, $sy1, $ro, $ro, $large, $ex1, $ey1, $sx2, $sy2, $ri, $ri, $large, $ex2, $ey2); + echo ''.htmlspecialchars($legend[$i]).''; + $angle = $end; } - $p1->SetCenter(0.35,0.55); - $p1->value->Show(false); - $p1->SetLegends($legend); + $lx = 290; $ly = 110; + foreach ($legend as $i => $line) { + $y = $ly + $i * 26; + echo ''; + echo ''.htmlspecialchars($line).''; + } - $graph->Add($p1); - $graph->Stroke(); + echo ''.date('m/d/Y').''; + echo ''; }