今天就跟大家聊聊有關使用Ajax與Jpgraph怎么實現一個動態折線圖功能,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結了以下內容,希望大家根據這篇文章可以有所收獲。
具體如下:
一 代碼
fun.js:
var i=1; function progress(){ setInterval("beginProgress()", 600); } function beginProgress(){ $("#img").attr("src", "img.php?m="+i); i++; if(i>=12){ i=1; } }
index.php:
Ajax+Jpgraph制作動態折線圖 ![]()
img.php:
SetScale("textlin"); $graph->SetShadow(); $graph->img->SetMargin(40, 30, 30, 70); $graph->title->Set("圖書銷售走勢表"); $lineplot1 = new LinePlot($data1); $graph->Add($lineplot1); $graph->xaxis->title->Set("月份"); $graph->yaxis->title->Set("book A銷售金額(萬元)"); $graph->title->SetFont(FF_SIMSUN, FS_BOLD); $graph->yaxis->title->SetFont(FF_SIMSUN, FS_BOLD); $graph->xaxis->title->SetFont(FF_SIMSUN, FS_BOLD); $lineplot1->SetColor('red'); $lineplot1->SetLegend('book A'); $graph->legend->SetLayout(LEGEND_HOR); $graph->legend->Pos(0.4, 0.95, 'center', 'bottom'); $graph->Stroke();
二 運行結果
看完上述內容,你們對使用Ajax與Jpgraph怎么實現一個動態折線圖功能有進一步的了解嗎?如果還想了解更多知識或者相關內容,請關注創新互聯行業資訊頻道,感謝大家的支持。