witam wszystkich
zachciało sie przez php ronic wykresy wiec poszukałem na necie opisów i bibliotek i znalazłem
ale teraz mam następujacy problem
jak przekazać do klasy która twoży wykresy dane w postaci tablicy
jak robie w następujacy sposób
<?php
$url="localhost";
$uzyt="xxxx";
$haslo="xxxx";
$b_danych="uszki";
@ mysql_connect($url,$uzyt,$haslo) or
die ("Nie mozna polaczyc sie z baza danych"); $query = "SELECT * FROM umowy";
$wartosc = 0;
);
echo $data[0][0].' , '.$data[0][1].' , '.$data[0][2].' , '.$data[0
][3
];
{
$query1 = "SELECT * FROM komsultanci WHERE id_k=".$row['id_k'];
if ($row['id_k']==1)
{
$data[0][1] = $data[0][1] + $row['kwota'];
$legenda[0] = $row1['imie'].' '.$row1['nazwisko'];
}
elseif ($row['id_k']==2)
{
$data[0][2] = $data[0][2] + $row['kwota'];
$legenda[1] = $row1['imie'].' '.$row1['nazwisko'];
}
elseif ($row['id_k']==3)
{
$data[0][3] = $data[0][3] + $row['kwota'];
$legenda[2] = $row1['imie'].' '.$row1['nazwisko'];
}
}
echo $data[0][0].' , '.$data[0][1].' , '.$data[0][2].' , '.$data[0
][3
]; $example_data = $data;
?>
<img src="index5.php" border="0" />
to jest index.php
a to index5.php
<?php
//Include the code
include('phplot.php');
$example_data = $data;
//Define the object
$graph =& new PHPlot(800,400);
$graph->SetDataType("text-data"); //Must be called before SetDataValues
$graph->SetDataValues($data);
$graph->SetLegend($legenda);
$graph->SetLegendPixels(530,20);
$graph->SetXTitle("Punkty kontrolne");
$graph->SetYTitle("Wyniki sprzedawców.");
$graph->SetYTickIncrement(5);
$graph->SetPlotType("pie ");
$graph->SetXLabelAngle(10); //have to re-set as defined above
$graph->SetNewPlotAreaPixels(70,10,500,300);
$graph->SetPlotAreaWorld(0,0,7,80);
$graph->DrawGraph();
//Print the image
$graph->PrintImage();
?>
z kolei w nastepujacy sposób mi działa ale niezabardzo mi sie to podoba
<?php
//Include the code
include('phplot.php');
//Define the object
$graph =& new PHPlot(800,400);
$url="localhost";
$uzyt="xxx";
$haslo="xx";
$b_danych="uszki";
@ mysql_connect($url,$uzyt,$haslo) or
die ("Nie mozna polaczyc sie z baza danych"); $query = "SELECT * FROM umowy";
$wartosc = 0;
);
{
$query1 = "SELECT * FROM komsultanci WHERE id_k=".$row['id_k'];
if ($row['id_k']==1)
{
$data[0][1] = $data[0][1] + $row['kwota'];
$legenda[0] = $row1['imie'].''.$row1['nazwisko'];
}
elseif ($row['id_k']==2)
{
$data[0][2] = $data[0][2] + $row['kwota'];
$legenda[1] = $row1['imie'].' '.$row1['nazwisko'];
}
elseif ($row['id_k']==3)
{
$data[0][3] = $data[0][3] + $row['kwota'];
$legenda[2] = $row1['imie'].' '.$row1['nazwisko'];
}
}
$example_data = $data;
$graph->SetDataType("text-data"); //Must be called before SetDataValues
$graph->SetDataValues($example_data);
$graph->SetLegend($legenda);
$graph->SetLegendPixels(530,20);
$graph->SetXTitle("Punkty kontrolne");
$graph->SetYTitle("Wyniki sprzedawców.");
$graph->SetYTickIncrement(5);
$graph->SetPlotType("pie ");
$graph->SetXLabelAngle(10); //have to re-set as defined above
$graph->SetNewPlotAreaPixels(70,10,500,300);
$graph->SetPlotAreaWorld(0,0,7,80);
$graph->DrawGraph();
//Print the image
$graph->PrintImage();
?>