JpGraph サンプル

← 一覧に戻る
<?php // content="text/plain; charset=utf-8"
// A medium complex example of JpGraph
// Note: You can create a graph in far fewwr lines of code if you are
// willing to go with the defaults. This is an illustrative example of
// some of the capabilities of JpGraph.

require_once ("jpgraph/jpgraph.php");
require_once ("jpgraph/jpgraph_line.php");
require_once ("jpgraph/jpgraph_bar.php");


// Create some datapoints 
for($i=0; $i<$steps; ++$i) {
	$databarx[]=sprintf("198%d %s",floor($i/12),$month[$i%12]);
	if( $i % 6 == 0 && $i<$steps-6) {
	else {

// New graph with a background image and drop shadow
$graph = new Graph(450,300);

// Use text X-scale so we can text labels on the X-axis

// Y2-axis is linear

// Color the two Y-axis to make them easier to associate
// to the corresponding plot (we keep the axis black though)

// Set title and subtitle
$graph->title->Set("Combined bar and line plot");
$graph->subtitle->Set("100 data points, X-Scale: 'text'");

// Use built in font (don't need TTF support)

// Make the margin around the plot a little bit bigger then default

// Slightly adjust the legend from it's default position in the
// top right corner to middle right side

// Display every 6:th tickmark

// Label every 2:nd tick mark

// Setup the labels

// Create a red line plot
$p1 = new LinePlot($datay);

// Create the bar plot
$b1 = new BarPlot($databary);

// Drop shadow on bars adjust the default values a little bit

// The order the plots are added determines who's ontop

// Finally output the  image


← 一覧に戻る