Open Flash Chart
Support This Project :: Home - Gallery - Background Image
Info: Open Flash Chart 2 is out. Version 1.x and these pages will never disappear and the charts will continue working forever, but further development on 1.x has stopped. Take a look at version 2 here Open Flash Chart 2.

Gallery - Background Image

Method: set_bg_image()

set_bg_image( string $url[, string $x][, string $y] )
$url, the image URL.
$x can be one of the following strings:
  • center
  • left
  • right
$y can be one of the following strings:
  • middle
  • top
  • bottom
Both $x and $y must be passed as strings, e.g:
$g->set_bg_image( 'http://teethgrinder.co.uk/open-flash-chart/images/logo.png', 'right', 'top' );
or in the following example, the image would be in the middle of the chart:
$g->set_bg_image( 'http://teethgrinder.co.uk/open-flash-chart/images/logo.png', 'center', 'middle' );

Tip: Don't forget that you can edit your image to have a 20 pixel blank border around it so it is not 'squished' up against the edge of the chart.

Create the flash object
<?php
include_once 'ofc-library/open_flash_chart_object.php';
open_flash_chart_object'100%'200'http://'$_SERVER['SERVER_NAME'] .'/open-flash-chart/gallery-data-23.php' );
?>
gallery-data-23.php
<?php

// generate some random data
srand((double)microtime()*1000000);

$data = array();
$xaxis = array();

for( 
$i=0$i<30$i++ )
{
  
$tmp rand(5,$i+5);
  
$data[] = $tmp;
  
$xaxis[] = $tmp;
}

include_once( 
'ofc-library/open-flash-chart.php' );
$g = new graph();
$g->title'Background Image''{font-size: 30px; color: #7E97A6}' );

$g->bg_colour '#E2E6E0';

//
//
$g->set_bg_image'http://teethgrinder.co.uk/open-flash-chart/images/logo.png''right''top' );
//
//

$g->set_data$data );
$g->line_hollow35'#7E97A6''Fatal kitten attacks in 2007'10 );

$g->x_axis_colour'#818D9D''#ADB5C7' );
$g->y_axis_colour'#818D9D''#ADB5C7' );

$g->set_y_max40 );
$g->y_label_steps);
$g->set_y_legend'Attacks'12'#7E97A6' );
echo 
$g->render();
?>
To see the data produced : gallery-data-23.php, then 'view source'.
Help support the project: Support This Project

Adverts: