<?php

require_once "./jpgraph/src/jpgraph.php";
require_once "./jpgraph/src/jpgraph_line.php";
require_once "./jpgraph/src/jpgraph_bar.php";
//CARGA DE DATOS
session_start();
$conexion = mysql_connect("localhost", "root", "");
mysql_select_db("logistica");
$consulta = mysql_query("SELECT * FROM v_transportes_km");
while ($reg = mysql_fetch_array($consulta)) {
    $id_vehiculo[] = $reg['id_transporte'];
    $kms[] = $reg['kms'] / 1000;
}
// DEFINICION DE FORMATO GENERALES
$ancho = 600;
$alto = 600;
$graph = new Graph($ancho, $alto, 'auto');
$graph->SetScale('textlin');
$graph->title->set("COMPARATIVO DE KM POR UNIDAD");
$graph->xaxis->title->set("Nro. Interno");
$graph->xaxis->SetTickLabels($id_vehiculo);
$graph->yaxis->title->set("Kilometros x 1000");
$grafico = new barPlot($kms);
$grafico->SetWidth(30);
$graph->Add($grafico);
$graph->Stroke();
$ydata = array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
$ydata2 = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
$targ = array("#1", "#2", "#3", "#4", "#5", "#6", "#7", "#8", "#9", "#10");
$alt = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
// Create the graph.
$graph = new Graph(300, 200);
$graph->SetScale("textlin");
$graph->img->SetMargin(40, 20, 30, 40);
$graph->title->Set("CSIM example with bar and line");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
// Setup axis titles
$graph->xaxis->title->Set("X-title");
$graph->yaxis->title->Set("Y-title");
// Create the linear plot
$lineplot = new LinePlot($ydata);
$lineplot->mark->SetType(MARK_FILLEDCIRCLE);
$lineplot->mark->SetWidth(5);
$lineplot->mark->SetColor('black');
$lineplot->mark->SetFillColor('red');
$lineplot->SetCSIMTargets($targ, $alt);
// Create line plot
$barplot = new barPlot($ydata2);
$barplot->SetCSIMTargets($targ, $alt);
// Add the plots to the graph
$graph->Add($lineplot);
$graph->Add($barplot);
$graph->StrokeCSIM();
?>


Exemple #3
0
$graph->SetScale("textlin");
$graph->img->SetMargin(40, 20, 30, 40);
$graph->title->Set("Chart Analysis");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$graph->SetScale('linlin', 100, 160);
$graph->yaxis->scale->ticks->Set(10);
$graph->xaxis->SetTickLabels($darr);
// Setup axis titles
$graph->xaxis->title->Set("Datetime");
$graph->yaxis->title->Set("Blood pressure");
// Create the linear plot
$lineplot = new LinePlot($arr);
$lineplot->mark->SetType(MARK_FILLEDCIRCLE);
$lineplot->mark->SetWidth(8);
$lineplot->mark->SetColor('black');
$lineplot->mark->SetFillColor('red');
$lineplot->SetCSIMTargets($targ, $alt);
// Create line plot
$barplot = new barPlot($arr);
$barplot->SetCSIMTargets($targ, $alt);
// $barplot ->mark->SetColor('blue');
$barplot->SetFillColor('#2EFEF7');
// Add the plots to the graph
$graph->Add($lineplot);
// $graph->Add($barplot);
$graph->StrokeCSIM();
?>