|
Warning: There is a bug when using the on-show animation. It screws up the tooltips.
This goes into the <head> of the page:
<script type="text/javascript" src="js/swfobject.js"></script>
<script type="text/javascript">
swfobject.embedSWF(
"open-flash-chart.swf", "my_chart",
"550", "300", "9.0.0", "expressInstall.swf",
{"data-file":"gallery/candle-chart.php"} );
</script>
This writes the chart into a div with id="my_chart",
right click and view source to see it in action,
[the tutorials have more details]
gallery/candle-chart.php
<?php
include '../php-ofc-library/open-flash-chart.php';
$title = new title( date("D M d Y") );
$data = array();
for($i=0; $i<31; $i++ ) { $high = (sin($i/2)*4) + 16; $open = $high - 4 - (sin($i/2)*2); $close = $high - 4 -(cos($i/2)*2); $low = $high - 8; if( abs($open-$close) < 0.3 ) { // force a Doji // (http://en.wikipedia.org/wiki/Candlestick_chart) $open = $close; } $data[] = new candle_value( number_format($high, 2), number_format($open, 2), number_format($close, 2), number_format($low, 2)); }
$candle = new candle('#9933CC'); $candle->set_values($data); $candle->set_tooltip('#x_label#<br>High: #high#<br>Open: #open#<br>Close: #close#<br>Low: #low#'); //$candle->set_on_show(new bar_on_show('drop', .9, 0));
$y = new y_axis(); $y->set_range( 0, 40, 10);
$chart = new open_flash_chart(); $chart->set_title( $title ); $chart->add_element( $candle ); $chart->set_y_axis( $y );
echo $chart->toPrettyString();
|
Adverts:
|