Open Flash Chart
Support This Project :: Home - Gallery - Tool Tip
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 - Tool Tip

set_tool_tip()

set_tool_tip( string $tip )
The tool tip string has (due to popular demand) lots of magic values to remember.

  • The text #val# is replaced with the actual value of whatever the mouse is over.

    So in our example above the tool tip is set:

    $g->set_tool_tip( 'Price: #val#.00' );
    
    so as the mouse is moved over various elements, the actual value is inserted into the tooltip string, replacing the #val#. For example the value 2 becomes the tooltip Price: 2.00.

  • The text #key# is replaced with the key string. So
    $g->set_tool_tip( '#key#: #val#.00' );
    
    would display 'Earnings: 2.00'.
  • The text <br> is a newline.

  • The text #x_label# is replaced with the X label string. So

    $g->set_tool_tip( '#key#<br>#x_label#: #val#.00' );
    
    would display (depending on what you are mouse overing):
    Earnings
    Jan: 2.00

  • The text #x_legend# is replaced with the X axis legend text.

  • The text #tip# is replaced with any extra text you want to display for a single data point or bar in a bar chart.

If no tooltip is set, the default is to show the #x_label# value as the title and the #val# on the second line.

If there are many lines of tooltip, the first line is the title, and the others are displayed below it. If there is only one line, it is displayed as normal, not as a title.

Create the flash object
<?php
include_once 'ofc-library/open_flash_chart_object.php';
open_flash_chart_object450250'http://'$_SERVER['SERVER_NAME'] .'/open-flash-chart/gallery-data-28.php' );
?>
gallery-data-28.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(2,5);
  
$data_2[] = rand(4,7);
}

include_once( 
'ofc-library/open-flash-chart.php' );
$g = new graph();
$g->title'Tool Tip Example''{font-size: 35px; color: #738995}' );

$g->set_data$data_1 );
$g->bar50'#7D8E99''Earnings'10 );

$g->set_data$data_2 );
$g->line_hollow35'#799191''Savings'10 );    // <-- 3px thick + dots

//
//
//
$g->set_tool_tip'#key#: #val#.00 (#x_label#, #x_legend#)<br>Key: #key#<br>X Label: #x_label#<br>Val: #val#.00<br>X Legend: #x_legend#' );
//
//
//

$g->set_x_labels( array( 'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep' ) );
$g->set_y_max10 );
$g->y_label_steps);

$g->set_y_legend'Money'12'#000000' );
$g->set_x_legend'2007'12'#000000' );

$g->bg_colour '#F0F0F0';
$g->set_inner_background'#DDEFFA''#CBD7E6'90 );

$g->x_axis_colour'#FFFFFF''#FFFFFF' );
$g->y_axis_colour'#FFFFFF''#FFFFFF' );

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

Adverts: