XML/SWF Charts| SlickBoard| Timeline Eons(New)

 < previousnext > 

 

link_data

 

<link_data url='string'
           target='string'

           legend='boolean'
           category='boolean'
      
           timeout='number'
           retry='number'
           spinning_wheel='boolean'
           wheel_x='number'
           wheel_y='number'
           /> 


Description

link_data sets the URL of a script responsible for processing clicks on chart elements. This enables drilling down into charts.

This feature is available to registered users only. Unregistered software links all charts to this website.

 

  • url: Relative or absolute URL of a script to process clicks on chart elements.

  • target: The window to open the resulting page in. Valid values are:

    • _self: opens the link in the same window (default).
    • _blank: opens the link in a new blank window.
    • _parent: opens the link in the immediate frameset parent.
    • _top: opens the link in the full body of the window .
    • string: opens the link in the window named <string>. If this window doesn't exist, a new window is opened and named <string>.
    • update: updates the chart without reloading the web page. This allows drilling down into the chart without reloading the web page. In this case, the script must be similar to that used in the update feature
    • javascript: calls a javascript function in the web page to respond to clicks.

  • legend: A boolean that determines whether to add links to the legend labels defined by chart_data or not. Valid values are true or false. The default is false.

  • category: A boolean that determines whether to add links to the category labels defined by chart_data or not. Valid values are true or false. The default is false.

  • timeout: If link_data's target is set to update, this attribute sets the number of seconds to wait before loading the update times out. The default is 30 seconds.

  • retry: If link_data's target is set to update, this attribute sets the number of times to try loading the update before displaying a loading error message. The default is 2 (try twice).

  • spinning_wheel: If link_data's target is set to update, this attribute determines whether to display a spinning wheel while loading the update or not. The default is false (do not display a spinning wheel).

  • wheel_x: The spinning wheel is centered by default in the chart area. This attribute determines a different horizontal position for the wheel. The default is omitted.

  • wheel_y: The spinning wheel is centered by default in the chart area. This attribute determines a different vertical position for the wheel. The default is omitted.

 


Click-Variables

link_data's URL should point to a script to process clicks and provide the user with additional information. When the user clicks a graph, information about the clicked element gets appended to the URL before calling it. A script on the other end should read which element was clicked and process the action accordingly.

The information appended to the URL is based on the way the chart's data is organized under chart_data:

  2006 2007 2008 2009
Region A 5 10 30 63
Region B 100 20 65 55
Region C 56 21 5 90

 

For example, in the above chart, if the user clicks the column representing the value 100 for region B in the year 2001, then link_data calls the URL set in the url parameter after appending "col=1&row=2&value=100&category=2001&series=Region B&x=102&y=94" to it. This gives the column & row coordinates of the corresponding value in the data table (the top-left cell starts at column zero, row zero,) plus the value itself, the category label, and the series label. X & y correspond to the mouse-click location.

If the URL in link_data's URL parameter is:

http://yourServer/script.php

Then the URL that link_data calls is:

http://yourServer/script.php?col=1&row=2&value=100&category=2001&series=Region B&x=102&y=94

The script in the "script.php" document should read the click-variables and respond accordingly. This script can either generate a new chart with more details (drill down into the chart,) or provide other types of information. This script can either generate the entire response, or redirect the request to other web pages (see examples below.)

Clickable chart elements are all those representing the data values.

 


Additional Variables

Different projects have different needs. The link_data function is intentionally generic to accommodate any and all needs. It's up to your script to translate the click-variables to any other information.

In some cases, you might need more than the click-variables to process a user request. For example, you might need to know which chart was clicked, and which client clicked it. In this case, include references in the URL like this:

http://yourServer/script.php?clientID=56745&chartID=10

The URL that link_data calls is:

http://yourServer/script.php?clientID=56745&chartID=10&col=1&row=2&value=100&category=2001&series=Region B&x=102&y=94

Some browsers might truncate very long URLs. If the variables are very log, avoid appending them to the URL. Save and retrieve them on the server instead.

 


Additional URLs

By default, link_data points only to one script URL that reads which element was clicked and processes the action accordingly (see Click-Variables above). This is a very efficient way to link the entire chart, and it is highly recommended when the chart has numourous data points that cannot be linked to individual URLs.

To override the link_data URL and link one or more data points to different URLs, use chart_data link.

 


Link_data to Javascript

To make a javascript function respond to a click on a chart, see Link_data to Javascript on this page.

 


Link and Link_data

If links are defined using both link and link_data, and the two overlap, then link_data has a higher priority. This allows using link to define a clickable rectangle covering the whole background to catch clicks not processed by link_data.

 

 

Example

<chart>

   <!-- relative url. Script document: link_data.php -->
   <link_data url='link_data.php' target='_blank' /> 

</chart>

 

The script in "link_data.php" reads the variables like this:

<?php
$column =  $_REQUEST['col'];
$row = $_REQUEST['row'];
$value = $_REQUEST['value'];
$category = $_REQUEST['category'];
$series = $_REQUEST['series'];
$x = $_REQUEST['x'];
$y = $_REQUEST['y'];
?>

 

The script might process the request like this:

<?php

switch ( $_REQUEST['row'] ){
   case 1:
   echo "Region A data was clicked.";
   break;
	
   case 2:
   echo "Region B data was clicked.";
   break;
}

?>

 

Or, it might redirect the request to other web pages like this:

<?php
//no text should be sent to the browser before a redirect. Make sure there are no spaces before "<?php"

//table of web pages to redirect the request to (corresponds to the chart's data table)
$url = array ( array ( "", "",                   "",                   "" ),
               array ( "", "http://server/page", "http://server/page", "http://server/page" ),
               array ( "", "http://server/page", "http://server/page", "http://server/page" ),
               array ( "", "http://server/page", "http://server/page", "http://server/page" )
             );

//redirect
Header("Location: " . $url [ $_REQUEST['row'] ][ $_REQUEST['col'] ] );

//no text should be sent to the browser after a redirect.
exit;

?>

 

 < previousnext > 


Copyright 2003-2014, maani.us