0
我有一個混合圖表,我希望我的數據集可以自動更新工作週數與預期數(棒)以及兩個投影示例(線)的對照表。如何讓@data自動更新圖形,以便不必手動輸入?我如何讓我的GD :: Graph自動更新?
以下是我一直在處理的內容: (爲了簡化示例,該表爲第一行「W25」的數據...並且第三行,即第一行,其中最後一個數字是6.4後,我會處理的人,讓他們硬編碼現在)是在網頁製作表格的
例:
print "<p>\n";
print "<TABLE BORDER=1>\n";
print "<caption>Projected Weekly Output</caption>\n";
print "<TR><TH>WW<TH>Wafers\n";
foreach $ww (sort keys %ww_proj_hash)
{
$qty_outs = $ww_proj_hash{$ww};
print "<TR><TD>$ww <TD align=center>$qty_outs\n";
}
print "</TABLE><p>\n";
$ WW是第1行和$ qty_outs第3行產生與下面硬編碼非常相似的結果。
my @data = (
[ "W25", "W26", "W27", "W28", "W29", "W30", "W31", "W32", "W33", "W34", "W35"],
[ 1, 2, 2.8, 3.6, 4, 5, 5.5, 6, 7, 7.5, 8 ],
[ 1, 2, 2.8, 3.6, 4.4, 5.6, 6.4 ],
[ 1, 1.95, 2.7, 3.4, 3.7, 4.7, 5, 5.5 ],
);
my $graphmixed = GD::Graph::mixed->new (500,350);
$graphmixed->set(
x_label => 'X Label',
y_label => 'Y label',
title => 'Projected Supply vs. Request',
t_margin => 5,
b_margin => 2,
l_margin => 5,
r_margin => 5,
y_min_value => 0,
y_max_value => 8,
y_tick_number => 8,
y_label_skip => 3,
cumulate => 1,
types => [qw(bars lines lines)],
dclrs => [qw(#4f81bd #98B954 #BE4B57)],
borderclrs => [qw(black)],
fgclr => black,
textclr => black,
labelclr => black,
axislabelclr => black,
y_long_ticks => 1,
line_width => 4,
bar_spacing => 10,
transparent => 0,
) or warn $graphmixed->error;
$tmp_trend_file = 'graphmixed.png';
open(IMG, ">$tmp_trend_file") or die $!;
binmode IMG;
print IMG $graphmixed->plot(\@data)->png();
close IMG;
print "<p><img src=$tmp_trend_file border=1><p>\n";
這聽起來像你可能實際上想要使用JavaScript圖形庫,例如Highcharts,D3,Plotly等。 –
你是什麼意思?「我如何讓@data自動更新圖形,以便它不必手動輸入?」 - 你的意思是你想讓數據數組填入與HTML表中相同的值,而不是硬編碼它們? –