myibs
-
Content count
7 -
Joined
-
Last visited
Posts posted by myibs
-
-
Sorry, I' m not create the XML page because I'm following the example in BasicDBExample.
It just have FusionCharts.php,DBConn.php, n FusionCharts.js.
I think without generate the xml,still can run that page/code right?
-
Here I d code has been modified from me:
<?php
//We've included ../Includes/FusionCharts.php and ../Includes/DBConn.php, which contains
//functions to help us easily embed the charts and connect to a database.
include("../Includes/FusionCharts.php");
include("../Includes/DBConn2.php");
?>
<HTML>
<HEAD>
<TITLE>
FusionCharts Free - Database Example
</TITLE>
<?php
//You need to include the following JS file, if you intend to embed the chart using JavaScript.
//Embedding using JavaScripts avoids the "Click to Activate..." issue in Internet Explorer
//When you make your own charts, make sure that the path to this JS file is correct. Else, you would get JavaScript errors.
?>
<script LANGUAGE="Javascript" SRC="../../FusionCharts/FusionCharts.js"></SCRIPT>
<style type="text/css">
<!--
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
.text{
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
-->
</style>
</HEAD>
<BODY>
<CENTER>
<h2><a href="http://www.fusioncharts.com" target="_blank">FusionCharts Free</a> -Database and Drill-Down Example</h2>
<?php
//In this example, we show how to connect FusionCharts to a database.
//For the sake of ease, we've used an MySQL databases containing two
//tables.
// Connect to the DB
$link = connectToDB();
// SQL query for category labels
$strQueryCategories = "select Bay.timelastupdate AS TimeOnly FROM Bay WHERE datelastupdate = CURRENT_DATE ORDER BY TimeOnly";
// Query database
$resultCategories = mysql_query($strQueryCategories) or die(mysql_error());
// SQL query for factory output data
$strQueryData = "SELECT BayName.BayNames, Bay.timelastupdate AS TimeOnly, Bay.Quantity FROM BayName, Bay WHERE BayName.BayId = Bay.BayId and datelastupdate = CURRENT_DATE ORDER BY timelastupdate DESC LIMIT 5";
// Query database
$resultData = mysql_query($strQueryData) or die(mysql_error());
//We also keep a flag to specify whether we've to animate the chart or not.
//If the user is viewing the detailed chart and comes back to this page, he shouldn't
//see the animation again.
//$strXML will be used to store the entire XML document generated
//Generate the chart element
$strXML = "<chart legendPosition='' caption='Status Car In/Out' subCaption='Daily Transaction' xAxisName='Bay Name' yAxisName='Units' showValues='0' formatNumberScale='0' rotateValues='1' animation='1'>";
// Build category XML
$strXML .= buildCategories ($resultCategories, "TimeOnly");
// Build datasets XML
$strXML .= buildDatasets ( $resultData, "Quantity", "BayNames");
//Finally, close <chart> element
$strXML .= "</chart>";
//Create the chart - Pie 3D Chart with data from strXML
echo renderChart("../../FusionCharts/MSLine.swf", "", $strXML, "StatusCar", 700, 400);
// Free database resource
mysql_free_result($resultCategories);
mysql_free_result($resultData);
mysql_close($link);
/***********************************************************************************************
* Function to build XML for categories
* @param $result Database resource
* @param $labelField Field name as String that contains value for chart category labels
*
* @return categories XML node
*/
function buildCategories ( $result, $labelField )
{
$strXML = "";
if ($result) {
$strXML = "<categories>";
while($ors = mysql_fetch_array($result)) {
$strXML .= "<category label='" . $ors[$labelField]. "'/>";
}
$strXML .= "</categories>";
}
return $strXML;
}
/***********************************************************************************************
* Function to build XML for datasets that would contain chart data
* @param $result Database resource. The data should come ordered by a control break
field which would require to identify datasets and set its value to
dataset's series name
* @param $valueField Field name as String that contains value for chart dataplots
* @param $controlBreak Field name as String that contains value for chart dataplots
*
* @return Dataset XML node
*/
function buildDatasets ($result, $valueField, $controlBreak )
{
$strXML = "";
if ($result) {
$controlBreakValue ="";
while( $ors = mysql_fetch_array($result) ) {
if( $controlBreakValue != $ors[$controlBreak] )
{
$controlBreakValue = $ors[$controlBreak];
$strXML .= ( $strXML =="" ? "" : "</dataset>") . ( "<dataset seriesName='" . $controlBreakValue . "'>" ) ;
}
$strXML .= "<set value='" . $ors[$valueField] . "'/>";
}
$strXML .= "</dataset>";
}
return $strXML;
}
?>
<BR><BR>
<a href='../NoChart.html' target="_blank">Unable to see the chart above?</a>
<H5 ><a href='../default.htm'>« Back to list of examples</a></h5>
</CENTER>
</BODY>
</HTML>
see d attachment of that chart, it should'nt be like that..
please refer example of data in d database.
why the dot value not plot at the right track(time).
As u can see, Time 15:51:23,should be have 12 Quantity but it doesnt.
Please help me on that..
Thanks
-
Hi there,
I'm trying to follow d example given at FusionChart XT Doc (Home > Guide for web developers > Using with PHP > Plotting from database)
(under topic multi-series line chart )...
It not display any data..Here i paste the code..
Please somebody see whats wrong on this code..
thanks..
<?php
//We've included ../Includes/FusionCharts.php and ../Includes/DBConn.php, which contains
//functions to help us easily embed the charts and connect to a database.
include("../Includes/FusionCharts.php");
include("../Includes/DBConn.php");
?>
<HTML>
<HEAD>
<TITLE>
FusionCharts Free - Database Example
</TITLE>
<?php
//You need to include the following JS file, if you intend to embed the chart using JavaScript.
//Embedding using JavaScripts avoids the "Click to Activate..." issue in Internet Explorer
//When you make your own charts, make sure that the path to this JS file is correct. Else, you would get JavaScript errors.
?>
<script LANGUAGE="Javascript" SRC="../../FusionCharts/FusionCharts.js"></SCRIPT>
<style type="text/css">
<!--
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
.text{
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
-->
</style>
</HEAD>
<BODY>
<CENTER>
<h2><a href="http://www.fusioncharts.com" target="_blank">FusionCharts Free</a> -Database and Drill-Down Example</h2>
<?php
//In this example, we show how to connect FusionCharts to a database.
//For the sake of ease, we've used an MySQL databases containing two
//tables.
// Connect to the DB
$link = connectToDB();
// SQL query for category labels
$strQueryCategories = "select distinct DATE_FORMAT(factory_output.DatePro,'%c-%d-%Y') as DatePro from factory_output order by DatePro";
// Query database
$resultCategories = mysql_query($strQueryCategories) or die(mysql_error());
// SQL query for factory output data
$strQueryData = "select factory_master.FactoryName, DATE_FORMAT(factory_output.DatePro,'%c-%d-%Y') as DatePro, factory_output.Quantity from factory_master factory_master, factory_output factory_output where factory_output.FactoryID = factory_master.FactoryId order by factory_output.FactoryID, factory_output.DatePro";
// Query database
$resultData = mysql_query($strQueryData) or die(mysql_error());
//We also keep a flag to specify whether we've to animate the chart or not.
//If the user is viewing the detailed chart and comes back to this page, he shouldn't
//see the animation again.
//$strXML will be used to store the entire XML document generated
//Generate the chart element
$strXML = "<chart legendPosition='' caption='Factory Output report' subCaption='By Quantity' xAxisName='Factory' yAxisName='Units' showValues='0' formatNumberScale='0' rotateValues='1' animation='1'>";
// Build category XML
$strXML .= buildCategories ($resultCategories, "DatePro");
// Build datasets XML
$strXML .= buildDatasets ( $resultData, "Quantity", "FactoryName");
//Finally, close <chart> element
$strXML .= "</chart>";
//Create the chart - Pie 3D Chart with data from strXML
echo renderChart("../../FusionCharts/MSLine.swf", "", $strXML, "FactorySum", 700, 400);
// Free database resource
mysql_free_result($resultCategories);
mysql_free_result($resultData);
// mysql_close($link);
/***********************************************************************************************
* Function to build XML for categories
* @param $result Database resource
* @param $labelField Field name as String that contains value for chart category labels
*
* @return categories XML node
*/
function buildCategories ( $result, $labelField )
{
$strXML = "";
if ($result) {
$strXML = "<categories>";
while($ors = mysql_fetch_array($result)) {
$strXML .= "<category label='" . $ors[$labelField]. "'/>";
}
$strXML .= "</categories>";
}
return $strXML;
}
/***********************************************************************************************
* Function to build XML for datasets that would contain chart data
* @param $result Database resource. The data should come ordered by a control break
field which would require to identify datasets and set its value to
dataset's series name
* @param $valueField Field name as String that contains value for chart dataplots
* @param $controlBreak Field name as String that contains value for chart dataplots
*
* @return Dataset XML node
*/
function buildDatasets ($result, $valueField, $controlBreak )
{
$strXML = "";
if ($result) {
$controlBreakValue ="";
while( $ors = mysql_fetch_array($result) ) {
if( $controlBreakValue != $ors[$controlBreak] )
{
$controlBreakValue = $ors[$controlBreak];
$strXML .= ( $strXML =="" ? "" : "</dataset>") . ( "<dataset seriesName='" . $controlBreakValue . "'>" ) ;
}
$strXML .= "<set value='" . $ors[$valueField] . "'/>";
}
$strXML .= "</dataset>";
}
return $strXML;
}
?>
<BR><BR>
<a href='../NoChart.html' target="_blank">Unable to see the chart above?</a>
<H5 ><a href='../default.htm'>« Back to list of examples</a></h5>
</CENTER>
</BODY>
</HTML>
-
Okay,here I try the simple one, I'm not sure its right or wrong.
But,through all these codes, The data not run n display based what I want.
Actually, I want to display the status of car In/Out on current date (shows daily transaction) in every minute.
This data it just retrieve from table include time IN/OUT of that car.
XML Page
------------
<chart caption='Status Car In/Out' subCaption='Daily Transaction' dataStreamURL='IparkTransaction.php' refreshInterval='60' numberPrefix='' setAdaptiveYMin='1' xAxisName='Time' showRealTimeValue='1' realTimeValuePadding='50' labelDisplay='Rotate' slantLabels='1'>
<categories>
</categories>
<dataset seriesName='In' showValues='0'>
</dataset>
<dataset seriesName='Out' showValues='0'>
</dataset>
<styles>
<definition>
<style type='font' name='captionFont' size='14' />
</definition>
<application>
<apply toObject='Caption' styles='captionFont' />
<apply toObject='Realtimevalue' styles='captionFont' />
</application>
</styles>
</chart>
PHP page
--------------
<?php
include("Includes/DBConn.php");
//Get date Today - date format 2011-11-04
$dateTodayLabel = date("yy-d-m");
//Get label for the data - time in format hh:mn:ss
$dateTimeLabel = date('h:i:s');
// extract pertinent data from dataset
// we will get
$strSQLIn ="select count(EventTrans) where EventTrans = 'IN' and DateTrans=" . $_REQUEST['dateTodayLabel'] . " ";
$strSQLOut ="select count(EventTrans) where EventTrans = 'OUT' and DateTrans=" . $_REQUEST['dateTodayLabel'] . " ";
// execure SQL to create recordset
$resultIn=mysql_query($strSQLIn) or die(mysql_error());
$resultOut=mysql_query($strSQLOut) or die(mysql_error());
//Now write it to output stream
print "&label=" . $dateTimeLabel . "In=" . $resultIn . "Out" . $resultOut;
?>
HTML page
---------------
<HTML>
<HEAD>
<TITLE>FusionWidgets v3 - Multiple dataset example</TITLE>
<script type="text/javascript" src="../Charts/FusionCharts.js"></script>
</HEAD>
<BODY>
<CENTER>
<div id="chart1div">
This text is replaced by the Flash movie.
</div>
<script type="text/javascript">
var chart1 = new FusionCharts("../Charts/RealTimeLine.swf", "ChId1", "500", "350", "0", "0");
chart1.setDataURL("IparkData.xml");
chart1.render("chart1div");
</script>
</BODY>
</HTML>
And also I attached print screen on display page and my table.
Thanks
-
Thanks Angshu for d feedback.
Ok,if so.
Based on my understanding, before I create real time chart using php mysql,
here is the list of file/folder I need to copy from d example (blueprint):
1-_mmServerScripts folder
2-charts folder
3-Includes (change the dbconnection) folder
4-JSClass folder
5-Default.php - this one as a main page right,then I need to make a changes.
6-DataGen.php - the query data inside this page right, so I just change based on my requirement right?
but,how about the function which using XML language inside, I'm not very undertand
when to apply with the realtime.could u help me?
7-LibFunctions.php - no need to change right?
8-Utilities.php - no need to change right?
ok thanks a lot!
-
Hi there,
I'm a newbie with this software,just yesterday get to know and try this kind of software.
quite interesting and its challenging me to understand XML language that I never learned before.
I'm going to develop Real-time Line (Dual Y) which using php mysql as data backend.
I already try and run the example of Real-time Line (Dual Y) in d doc, but it just use the random data not extract from database(mysql)
Currently, the blueprint application (example in php mysql that I've downloaded) does not have d example Real-time Line (Dual Y).
I try to manipulate the example has given, but hard for me to manipulate it to do in Real-time Line (Dual Y).
So,anyone here have done it before and any example that I can refer straightly.
Thank u very much for your kindness to help me.
Multi-Series Line Chart
in FusionCharts Free and PHP
Posted · Report reply
If so,
how about this,whats wrong with my query below, why no data display on the graph:
*.php
-------
<?php
// These four parameters must be changed dependent on your MySQL settings
$hostdb = 'localhost'; // MySQl host
$userdb = 'root'; // MySQL username
$passdb = '123456'; // MySQL password
$namedb = 'ipark'; // MySQL database name
$link = mysql_connect ($hostdb, $userdb, $passdb);
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db($namedb);
if (!$db_selected) {
die ('Can\'t use database : ' . mysql_error());
}
return $link;
// extract pertinent data from dataset
// we will get
$resultSet ="SELECT BayIn as eventIn, BayOut as eventOut, date_format(timelastupdate, '%H:%i') AS time_only FROM BayAllocation WHERE datelastupdate = '2011-11-17' ORDER BY timelastupdate DESC LIMIT 5";
// execute SQL to create recordset
while($ors = mysql_fetch_array($resultSet)) {
$eventIn = $ors['eventIn'];
$eventOut = $ors['eventOut'];
$dateTimeLabel = $ors['timelastupdate'];
}
//Now write it to output stream*/
print "&label=" . $dateTimeLabel . "&value=" . $eventIn . "|" . $eventOut;
?>
*.xml
------
<chart caption='Status Car In/Out' subCaption='Daily Transaction' dataStreamURL='IparkTransaction3.php' refreshInterval='60' numberPrefix='' setAdaptiveYMin='1' xAxisName='Time' showRealTimeValue='5' realTimeValuePadding='50' labelDisplay='Rotate' slantLabels='5' >
<categories>
</categories>
<dataset seriesName='In' showValues='0'>
</dataset>
<dataset seriesName='Out' showValues='0'>
</dataset>
<styles>
<definition>
<style type='font' name='captionFont' size='14' />
</definition>
<application>
<apply toObject='Caption' styles='captionFont' />
<apply toObject='Realtimevalue' styles='captionFont' />
</application>
</styles>
</chart>
----Thanks---
fw1811.bmp