/** * Para el tipo de gráfico 'otro' hay que especificar todo lo referente a * jpgraph. Desde la inclusión de los archivos necesarios hasta la instanciación * de todas las componentes que esta necesita para generar un gráfico. * Lo único que hay que hacer es 'avisarle' al gráfico de toba cuál es el * canvas que se tiene que dibujar. Todo el resto es legal y bonito * * @param toba_ei_grafico $grafico */ function conf__grafico(toba_ei_grafico $grafico) { require_once toba_dir() . '/php/3ros/jpgraph/jpgraph.php'; require_once toba_dir() . '/php/3ros/jpgraph/jpgraph_contour.php'; $data = array(array(0.5, 1.1, 1.5, 1, 2.0, 3, 3, 2, 1, 0.1), array(1.0, 1.5, 3.0, 5, 6.0, 2, 1, 1.2, 1, 4), array(0.9, 2.0, 2.1, 3, 6.0, 7, 3, 2, 1, 1.4), array(1.0, 1.5, 3.0, 4, 6.0, 5, 2, 1.5, 1, 2), array(0.8, 2.0, 3.0, 3, 4.0, 4, 3, 2.4, 2, 3), array(0.6, 1.1, 1.5, 1, 4.0, 3.5, 3, 2, 3, 4), array(9.0, 1.5, 3.0, 5, 6.0, 2, 1, 1.2, 2.7, 4), array(9.800000000000001, 9.0, 3.0, 3, 5.5, 6, 3, 2, 1, 1.4), array(9.0, 1.5, 3.0, 4, 6.0, 5, 2, 1, 0.5, 0.2)); // Setup a basic graph context with some generous margins to be able // to fit the legend $canvas = new Graph(650, 300); $canvas->SetMargin(40, 140, 60, 40); $canvas->title->Set('Uso avanzado de la librería'); $canvas->title->SetFont(FF_ARIAL, FS_BOLD, 14); // For contour plots it is custom to use a box style ofr the axis $canvas->legend->SetPos(0.05, 0.5, 'right', 'center'); $canvas->SetScale('intint'); $canvas->SetAxisStyle(AXSTYLE_BOXOUT); $canvas->xgrid->Show(); $canvas->ygrid->Show(); // A simple contour plot with default arguments (e.g. 10 isobar lines) $cp = new ContourPlot($data); // Display the legend $cp->ShowLegend(); // Make the isobar lines slightly thicker $cp->SetLineWeight(2); $canvas->Add($cp); // Con esta llamada informamos al gráfico cuál es el gráfico que se tiene // que dibujar $grafico->conf()->canvas__set($canvas); }
<?php // content="text/plain; charset=utf-8" // Basic contour plot example require_once 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_contour.php'; $data = array(array(12, 7, 3, 15), array(18, 5, 1, 9), array(13, 9, 5, 12), array(5, 3, 8, 9), array(1, 8, 5, 7)); // Basic contour graph $graph = new Graph(350, 250); $graph->SetScale('intint'); // Show axis on all sides $graph->SetAxisStyle(AXSTYLE_BOXOUT); // Adjust the margins to fit the margin $graph->SetMargin(30, 100, 40, 30); // Setup $graph->title->Set('Basic contour plot with multiple axis'); $graph->title->SetFont(FF_ARIAL, FS_BOLD, 12); // A simple contour plot with default arguments (e.g. 10 isobar lines) $cp = new ContourPlot($data, 10, 1); // Display the legend $cp->ShowLegend(); $graph->Add($cp); // ... and send the graph back to the browser $graph->Stroke();
// Contour plot example 04 require_once 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_contour.php'; $data = array(array(12, 12, 10, 10, 8, 4), array(10, 10, 8, 14, 10, 3), array(7, 7, 13, 17, 12, 8), array(4, 5, 8, 12, 7, 6), array(10, 8, 7, 8, 10, 4)); // Setup a basic graph context with some generous margins to be able // to fit the legend $graph = new Graph(500, 380); $graph->SetMargin(40, 140, 60, 40); $graph->title->Set("Example of interpolated contour plot"); $graph->title->SetFont(FF_ARIAL, FS_BOLD, 14); $graph->title->SetMargin(10); // For contour plots it is custom to use a box style ofr the axis $graph->legend->SetPos(0.05, 0.5, 'right', 'center'); $graph->SetScale('intint'); // Setup axis and grids $graph->SetAxisStyle(AXSTYLE_BOXOUT); $graph->xgrid->SetLineStyle('dashed'); $graph->xgrid->Show(true); $graph->ygrid->SetLineStyle('dashed'); $graph->ygrid->Show(true); // A simple contour plot with 10 isobar lines and flipped Y-coordinates // Make the data smoother by interpolate the original matrice by a factor of two // which will make each grid cell half the original size $cp = new ContourPlot($data, 10, 2); $cp->UseHighContrastColor(true); // Display the legend $cp->ShowLegend(); // Make the isobar lines slightly thicker $graph->Add($cp); // ... and send the graph back to the browser $graph->Stroke();
<?php // content="text/plain; charset=utf-8" // Basic contour plot example require_once "jpgraph/jpgraph.php"; require_once "jpgraph/jpgraph_contour.php"; $data = array(array(0.5, 1.1, 1.5, 1, 2.0, 3, 3, 2, 1, 0.1), array(1.0, 1.5, 3.0, 5, 6.0, 2, 1, 1.2, 1, 4), array(0.9, 2.0, 2.1, 3, 6.0, 7, 3, 2, 1, 1.4), array(1.0, 1.5, 3.0, 4, 6.0, 5, 2, 1.5, 1, 2), array(0.8, 2.0, 3.0, 3, 4.0, 4, 3, 2.4, 2, 3), array(0.6, 1.1, 1.5, 1, 4.0, 3.5, 3, 2, 3, 4), array(1.0, 1.5, 3.0, 5, 6.0, 2, 1, 1.2, 2.7, 4), array(0.8, 2.0, 3.0, 3, 5.5, 6, 3, 2, 1, 1.4), array(1.0, 1.5, 3.0, 4, 6.0, 5, 2, 1, 0.5, 0.2)); // Basic contour graph $graph = new Graph(350, 250); $graph->SetScale('intint'); // Show axis on all sides $graph->SetAxisStyle(AXSTYLE_BOXOUT); // Adjust the margins to fit the margin $graph->SetMargin(30, 100, 40, 30); // Setup $graph->title->Set('Basic contour plot with multiple axis'); $graph->title->SetFont(FF_ARIAL, FS_BOLD, 12); // A simple contour plot with default arguments (e.g. 10 isobar lines) $cp = new ContourPlot($data); // Flip the data around its center line $cp->SetInvert(); // Display the legend $cp->ShowLegend(); $graph->Add($cp); // ... and send the graph back to the browser $graph->Stroke();
<?php // content="text/plain; charset=utf-8" // Contour plot example require_once "jpgraph/jpgraph.php"; require_once "jpgraph/jpgraph_contour.php"; $data = array(array(0.5, 1.1, 1.5, 1, 2.0, 3, 3, 2, 1, 0.1), array(1.0, 1.5, 3.0, 5, 6.0, 2, 1, 1.2, 1, 4), array(0.9, 2.0, 2.1, 3, 6.0, 7, 3, 2, 1, 1.4), array(1.0, 1.5, 3.0, 4, 6.0, 5, 2, 1.5, 1, 2), array(0.8, 2.0, 3.0, 3, 4.0, 4, 3, 2.4, 2, 3), array(0.6, 1.1, 1.5, 1, 4.0, 3.5, 3, 2, 3, 4), array(1.0, 1.5, 3.0, 5, 6.0, 2, 1, 1.2, 2.7, 4), array(0.8, 2.0, 3.0, 3, 5.5, 6, 3, 2, 1, 1.4), array(1.0, 1.5, 3.0, 4, 6.0, 5, 2, 1, 0.5, 0.2)); // Setup a basic graph context with some generous margins to be able // to fit the legend $graph = new Graph(500, 380); $graph->SetMargin(40, 140, 60, 40); $graph->title->Set('Example of contour plot'); $graph->title->SetFont(FF_ARIAL, FS_BOLD, 14); // For contour plots it is custom to use a box style ofr the axis $graph->legend->SetPos(0.05, 0.5, 'right', 'center'); $graph->SetScale('intint'); $graph->SetAxisStyle(AXSTYLE_BOXOUT); $graph->xgrid->Show(); $graph->ygrid->Show(); // A simple contour plot with default arguments (e.g. 10 isobar lines) $cp = new ContourPlot($data); // Display the legend $cp->ShowLegend(); // Make the isobar lines slightly thicker $cp->SetLineWeight(2); $graph->Add($cp); // ... and send the graph back to the browser $graph->Stroke();
<?php // content="text/plain; charset=utf-8" // Contour plot example require_once 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_contour.php'; $data = array(array(0.5, 1.1, 1.5, 1, 2.0, 3, 3, 2, 1, 0.1), array(1.0, 1.5, 3.0, 5, 6.0, 2, 1, 1.2, 1, 4), array(0.9, 2.0, 2.1, 3, 6.0, 7, 3, 2, 1, 1.4), array(1.0, 1.5, 3.0, 4, 6.0, 5, 2, 1.5, 1, 2), array(0.8, 2.0, 3.0, 3, 4.0, 4, 3, 2.4, 2, 3), array(0.6, 1.1, 1.5, 1, 4.0, 3.5, 3, 2, 3, 4), array(1.0, 1.5, 3.0, 5, 6.0, 2, 1, 1.2, 2.7, 4), array(0.8, 2.0, 3.0, 3, 5.5, 6, 3, 2, 1, 1.4), array(1.0, 1.5, 3.0, 4, 6.0, 5, 2, 1, 0.5, 0.2)); // Setup a basic graph context with some generous margins to be able // to fit the legend $graph = new Graph(500, 380); $graph->SetMargin(40, 140, 60, 40); // Enable antialias. Note with antiaaliasing only line weight=1 is supported. $graph->img->SetAntiAliasing(); $graph->title->Set("Example of contour plot"); $graph->title->SetFont(FF_ARIAL, FS_BOLD, 14); // For contour plots it is custom to use a box style ofr the axis $graph->legend->SetPos(0.05, 0.5, 'right', 'center'); $graph->SetScale('intint'); $graph->SetAxisStyle(AXSTYLE_BOXOUT); $graph->xgrid->Show(); $graph->ygrid->Show(); // A simple contour plot with 19 isobars and flipped vertical range $cp = new ContourPlot($data, 10, true); // Display the legend $cp->ShowLegend(); // Invert the legend to th lowest isobar is on top $cp->Invertlegend(); $graph->Add($cp); // ... and send the graph back to the browser $graph->Stroke();