Open Flash Chart
Support This Project :: Home - Gallery - X Axis Labels Orientation
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 - X Axis Labels Orientation

Horizontal:

$g->set_x_label_style( 10, '#9933CC', 0 );
Vertical:
$g->set_x_label_style( 10, '#9933CC', 1 );
45 degrees:
$g->set_x_label_style( 10, '#9933CC', 2 );

This example looks complicated, but is quite easy really! The three URLs above pass different values of 'o' on the URL, this is then put into the URL that Open Flash Chart will read the data file from. gallery-data-18.php then checks 'o' to see if we clicked on 'vertical' or '45 degrees'.

Please note how the chart resizes its self so the text always stays visible. That was tricky to get right.

Note there is a known bug in Open Flash Chart, unicode characters will not display if the text is rotated. I think this is a bug in flash.


Create the flash object
<?php
include_once 'ofc-library/open_flash_chart_object.php';
$url 'http://'$_SERVER['SERVER_NAME'] .'/open-flash-chart/gallery-data-18.php';

//
// we pass the URL variable 'o' to Open Flash Chart
// which will then load data from "gallery-data-18.php?o=1"
//
if( isset( $_GET['o'] ) )
  
$url .= '?o='$_GET['o'];

open_flash_chart_object500300$url );
?>

gallery-data-18.php
<?php

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

$data_1 = array();
$data_2 = array();

for( 
$i=0$i<9$i++ )
{
  
$data_1[] = rand(11,16);
  
$data_2[] = rand(16,20);
}


include_once( 
'ofc-library/open-flash-chart.php' );

$g = new graph();
$g->title'中文簡介''{font-size: 30px; color: #2693CF}' );
//$g->title = '中文簡介';

$g->set_data$data_1 );
$g->bar50'#639F45''Bar'14 );

$g->set_data$data_2 );
$g->line_dot44'#2693CF''Line'14 );

$g->set_x_labels(
    array( 
'中文簡介','February','March','April','May,æ ø å Æ Ø Å','June','July','August','September' )
    );

//
// the orientation is passed in on the URL as 'o',
// if it is not present we default to 0 (horizontal)
// else we pass the value to set_x_label_style
//
$o = isset($_GET['o'])?intval($_GET['o']):0;
$g->set_x_label_style13'#9933CC'$o );

$g->set_y_min10 );
$g->set_y_max20 );
$g->y_label_steps);

$g->set_y_legend'Open Flash Chart'14'#639F45' );
$g->set_x_legend'Open Flash Chart'14'#639F45' );

echo 
$g->render();
?>
To see the data produced : gallery-data-18.php, then 'view source'.
Help support the project: Support This Project

Adverts: