|
charts image error |
Posted by Pankaj Arya on Nov-23-2010 18:39 |
|
Hi peter,
After following your very useful instruction,at least now i am getting the charts image properly with this code ....see image charts_image.png
$db = mysql_connect($server,$username,$password) or DIE("Connection to database failed, perhaps the service is down !!");
$db1=mysql_select_db($db_name) or DIE("Database name not available !!");
$login = mysql_query("Select TIMESTAMP, OPEN, HIGH, LOW, CLOSE, TOTTRDQTY From interactive WHERE SYMBOL='$ticker' ");
while ($row = mysql_fetch_assoc($login)) {
$timeStamps[] = chartTime2($row["TIMESTAMP"]);
$openData[] = $row["OPEN"];
$highData[] = $row["HIGH"];
$lowData[] = $row["LOW"];
$closeData[] = $row["CLOSE"];
$volData[] = $row["TOTTRDQTY"];
}
but if i edited financedemochart.php by pasting the above code in the below function ,its gives a image error as...No data available for the specified time period.
see image chartsimage.png
function generateRandomData($ticker, $startDate, $endDate, $resolution) {
global $timeStamps, $volData, $highData, $lowData, $openData, $closeData;
$db = mysql_connect($server,$username,$password) or DIE("Connection to database failed, perhaps the service is down !!");
$db1=mysql_select_db($db_name) or DIE("Database name not available !!");
$login = mysql_query("Select TIMESTAMP, OPEN, HIGH, LOW, CLOSE, TOTTRDQTY From interactive WHERE SYMBOL='$ticker' ");
while ($row = mysql_fetch_array($login, MYSQL_ASSOC))
{
$timeStamps[] = chartTime2($row[TIMESTAMP]);
$openData[] = $row[OPEN];
$highData[] = $row[HIGH];
$lowData[] = $row[LOW];
$closeData[] = $row[CLOSE];
$volData[] = $row[TOTTRDQTY];
}
}
Is it so because the variables from the database are an array or there is some another problem .and if the problem is with the array variables just tell me what can i do to resolve it.
|
Re: charts image error |
Posted by Peter Kwan on Nov-23-2010 23:35 |
|
Hi Pankaj,
The "No data available for the specified time period" is not an error. It just means exactly what it says - that there is no data available for the specified time period that can be plotted.
Note that if you copied from the sample code, the sample code is designed to removed the leading data points before plotting the chart. As you are using 25 days moving average, the sample code will remove at least 25 days. Even if you do not use moving average explicitly, the sample code will remove at least 20 days for the moving averages used in technical indicators. If your data have less than 25 points, then nothing can be plotted, and you will get the "No data ...." message.
To solve the problem, please provide more detail, or modify the sample code to not remove leading points (set extraPoints to 0).
Hope this can help.
Regards
Peter Kwan |
|