XML/SWF Gauge  1.6 | XML/SWF Charts | SlickBoard(New)

 < previousnext > 

 

update

 

<update url='string'
        delay='float'
        delay_type='int'
        stop_sound='boolean'
        timeout='int'
        retry='int'
        /> 


Description

update updates the gauge at intervals, without reloading the web page. This makes it possible to display gauges with live updates, change the gauge's look over time for emphasis, or create a slideshow from different gauges.

 

  • url: Relative or absolute URL of an XML source to get the update from

  • delay: The delay in seconds before requesting the update. The actual interval between updates is this delay, plus the time it takes to request and receive the next update. Depending on the connection speed, the actual interval might be several seconds longer than this delay. Desktop applications using this tool could use short delays in fractions of a second. The default is zero

  • delay_type: Determines how updates affect the current animation. Valid values are:

    • 1: Start the delay from the time the gauge is loaded, but don't update the gauge until the current animation is over. This is the default delay_type

    • 2: Start the delay from the time the gauge is loaded, and update the gauge even if the current animation isn't over

    • 3: Start the delay from the end of the animation

  • stop_sound: Determines whether to stop previous sounds with this update or not. The default is false (don't stop previous sounds)

  • timeout: The number of seconds to wait before loading times out. The default is 30 seconds

  • retry: The number of times to try loading the update script before displaying an error message. The default is 0 (don't retry)

 


Update Source

The update source should contain the code to redraw the entire gauge, including the parts that don't change. Redraw the gauge in exactly the same way a new gauge is created.

 


Updating Pointers

To update the pointers' positions, redraw the entire gauge, and make the new pointers start from their last positions. See the example below.

To pass the last positions to the update script, use variables in the query part of the update URL:

 <update url='http://yourServer/yourXMLsource?pointer1=45&pointer2=150' delay='5' />   

 


Regular Updates

To update a gauge, plus schedule for the following update, use update again in the update script. See the example below.

Some browsers use cached updates instead of calling the update source repeatedly. This results in seeing only a few fresh updates. To avoid this problem, append the precise time or a random number to the update URL to keep it new:

 <update url='http://yourServer/yourXMLsource?microtime=0.92556600 1125499452' delay='5' />   

 


User-Triggered Updates

To create interactive gauges that respond to mouse clicks and javascript, see link.

 


Example

Start a gauge with a rotating pointer that moves 90 degrees from angle 45 to 135. Then call the update script every 4 seconds to make the pointer go back and forth between angle 45 and 135:

	
<gauge>
   
   <circle x='200' y='125' radius='100' fill_alpha='35' line_color='ff4400' line_thickness='10' />
           
   <rotate x='200' y='125' start='45' span='90' step='5'>
      <line x1='200' y1='50' x2='200' y2='125' thickness='5' />      
   </rotate>
   
   <update url='update.php?pointer_end=135' delay='4' delay_type='1' /> 

</gauge>
	

 

The script in "update.php" is a PHP script generating XML code. This can be any other scripting language generating the same XML code. This PHP script looks like this:

<?php

if( $_REQUEST['pointer_end'] == 135 ){
	
	$start = 135;
	$span = -90;
	
}else{

	$start = 45;
	$span = 90;

}

$end = $start + $span;

?>


<gauge>

   <circle x='200' y='125' radius='100' fill_alpha='50' line_color='ff4400' line_thickness='10' />

   <rotate x='200' y='125' start='<?php echo $start ?>' span='<?php echo $span ?>' step='5'>
      <line x1='200' y1='25' x2='200' y2='125' thickness='5' />      
   </rotate>
	
   <update url='update.php?pointer_end=<?php echo $end ?>µtime=<?php echo microtime() ?>' delay='4' delay_type='1' />

</gauge>


 

In this example, the script that updates the gauge is independent from the code that generates the initial gauge. However, the same update script can be called to both generate the initial gauge and to continue updating it.

 

 

 < previousnext > 


Copyright 2005-2020, maani.us