如何在PHP中创建钟形曲线图

时间:2011-10-23 02:40:34

标签: php probability

http://support.microsoft.com/kb/213930显示“如何创建钟形曲线图”。我需要使用尽可能接近php的东西来自动执行此操作。非常感谢如果有人可以指向我的某些图书馆/ api等,这将使这一切变得简单......

1 个答案:

答案 0 :(得分:6)

如果您不想直接使用GD库制作图表,可以考虑: jpgraphlibchart

我之前使用过libchart,但从不制作钟形曲线。

以下是jpgraph中的一个示例,它表示一种钟形曲线:

<?php
include ("jpgraph/jpgraph.php");
include ("jpgraph/jpgraph_bar.php");
$databary = array();
for ($i=0; $i<32*12; ++$i)
{
    $databary[$i] = 0;
}
for ($i=0; $i<100000; ++$i)
{
    $data = rand(0,31)+rand(0,31)+rand(0,31)+rand(0,31)+rand(0,31)+rand(0,31)+rand(0,31)+rand(0,31)+rand(0,31)+rand(0,31)+rand(0,31)+rand(0,31);
    $databary[$data] += 1;
}
$graph = new Graph(1024,768,'auto');
$graph->SetShadow();
$graph->SetScale("textlin");
$graph->title->Set("Elementary barplot with a text scale");
$graph->title->SetFont(FF_FONT1,FS_BOLD);
$b1 = new BarPlot($databary);
$b1->SetLegend("Temperature");
$graph->Add($b1);
$graph->Stroke();

?>