Tathagata
Tathagata

Reputation: 2065

How to Create a Bell Curve Chart in PHP

http://support.microsoft.com/kb/213930 shows "How to Create a Bell Curve Chart". I need to automate this with something that is as close to php as possible. Would really appreciate if someone can point me to some library/api etc that'll make this easy ...

Upvotes: 2

Views: 2971

Answers (1)

Luttiany Maslowski
Luttiany Maslowski

Reputation: 76

If you do not want to make the chart directly with the GD library you could consider: jpgraph and libchart.

I have used libchart before, but never to make a bell curve.

Here is an example in jpgraph that makes a type of bell curve:

<?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();

?>

Upvotes: 6

Related Questions