0

I'm dong a school assignment currently.It's an investment website which has interactive chart by using open-flash-chart with latest update. It's design is similar to google finance's interactive flash chart.
I have obtained share price data from yahoo finance by using the simplehtmldom. Hyperlink for share price data:http://finance.yahoo.com/q/hp?s=4707.KL&a=00&b=1&c=2003&d=11&e=27&f=2010&g=m

and then present the data(data.php) with open flash chart.

my question is, how we passing the share price data that we have obtained from yahoo finance to "data.php" which use to output the data for open flash chart.
The Open-flash-chart's method http://teethgrinder.co.uk/open-flash-chart-2/tutorial-4.php

my code: share price obtained

<?php
require_once("simple_html_dom.php");
$html=file_get_html("http://finance.yahoo.com/q/hp?s=4707.KL&a=00&b=1&c=2003&d=11&e=27&f=2010&g=m");
	foreach($html->find('td[class=yfnc_tabledata1]') as $e)
    	{	echo "$e->innertext . <br />";
                }
?>

code: data.php

<?php

include 'php-ofc-library/open-flash-chart.php';

$max = 20;
$tmp = array();

require_once("simple_html_dom.php");
$html=file_get_html("http://finance.yahoo.com/q/hp?s=4707.KL&a=00&b=1&c=2003&d=11&e=27&f=2010&g=m");
	foreach($html->find('td[class=yfnc_tabledata1]') as $e)
    	{	$tmp=$e->innertext;
			if ($tmp == 'int')
			{	$line = new line();
				$line->set_values( array() );
				}
		}

$title = new title( date("D M d Y") );

$chart = new open_flash_chart();
$chart->set_title( $title );
$chart->add_element( $line );
                    
echo $chart->toString();
?>

Can anyone give me some guidance for doing this?

Edited by alanlai: n/a

1
Contributor
1
Reply
2
Views
6 Years
Discussion Span
Last Post by alanlai
0

this is the code that built the data randomly.

<?php

include 'php-ofc-library/open-flash-chart.php';

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

$max = 20;
$tmp = array();
for( $i=0; $i<9; $i++ )
{
  $tmp[] = rand(0,$max);
}

$title = new title( date("D M d Y") );

$bar = new bar();
$bar->set_values( array(1,2,3,4,5,6,7,8,9) );

$chart = new open_flash_chart();
$chart->set_title( $title );
$chart->add_element( $bar );
                    
echo $chart->toString();


?>

how are we edit this code to accept the data we pass in instead of generate randomly?

Edited by alanlai: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.