siric
-
Content count
8 -
Joined
-
Last visited
Posts posted by siric
-
-
Hi,
I am trying to create a piechart under the following circumstances:
My each row in my table contains a gender. I want to be able to sum up the number of males and females and then plot that in a pie chart.
The query that I am using
SELECT SUM(gender = 'male') AS male, SUM(gender = 'female') AS female FROM markers;
presents 2 columns (male and female) with a count below. How is it possible to get this into the array for the chart seeing that the data required should be by row rather than column?
Query Results:
| male | female |
| 23 | 43 |
Should be
| male | 23 |
| female | 43 |
Thanks
Steve
-
Ok,
I think I got it..
I changed the print statement to print "value=".$util;
Thanks
-
Hi,
I am trying to get a real-time angular gauge with data from a mysql table. I am trying to use the dataStreamURL but my question is how do I get the returned data into the dial value?
Gauge.html
<div class="gen-chart-render"> <div id="chartContainer">FusionWidgets will load here</div> <script type="text/javascript"><!-- var myChart = new FusionCharts( "../../Charts/AngularGauge.swf", "myChartId", "400", "200", "0", "1" ); myChart.setXMLData('<chart lowerLimit="0" upperLimit="100" lowerLimitDisplay="Good" upperLimitDisplay="Bad" numberSuffix="%" showValue="1" dataStreamURL="getutil.php" refreshInterval="3">\n\ <colorRange>\n\ <color minValue="0" maxValue="50" code="8BBA00"/>\n\ <color minValue="50" maxValue="80" code="F6BD0F"/>\n\ <color minValue="80" maxValue="100" code="FF654F"/>\n\ </colorRange>\n\ <dials>\n\ <dial value="0" />\n\ </dials>\n\ </chart>'); myChart.render("chartContainer"); // --> </script> </div>
getutil.php
$username = "xxx"; $password = "yyy"; $db = "fusionchartsdb"; $hostname = "localhost"; // make connection to database mysql_connect($hostname, $username, $password) or die("Unable to connect to host $hostname"); mysql_select_db($db) or die("Unable to select database $db"); $portid='1'; $strSQL = "SELECT util from utilisation WHERE portid = '$portid'"; $result=mysql_query($strSQL) or die(mysql_error()); $util = mysql_result($result,0,"util"); print $util;
I have checked the getutl by itself and it is working fine.
Thanks
-
The print on $strXML gave this -
but the print on $chartHTML still gives 'No data to display".
As mentioned before, if I hard code the output from $strXML into the renderChart statement, it works.
-
Can I get some assistance please?
-
Ok,
I changed the echo to a read and that made it worse as the graph did not render when the actual XML was included in the statement.
Here is a stripped down version of the code.
<?
include("cbw/includes/FusionCharts.php");
include("cbw/includes/FC_Colors.php");
//$strXML will be used to store the entire XML document generated
//Generate the graph element
$strXML = "<graph caption='Factory Output report' subCaption='By Quantity' pieSliceDepth='30' showBorder='1' showNames='1' formatNumberScale='0' numberSuffix=' Reviews' formatNumber='1' formatNumberScale='1' thousandSeparator=',' decimalPrecision='0' anchorBorderColor='0033CC' showAlternateHGridColor='1' AlternateHGridColor='ff5904' divLineColor='ff5904' divLineAlpha='20' alternateHGridAlpha='5'>";
$startDate = date('Y-m', strtotime('-12 month'));
$total = 0;
$businessId = '8';
for ($i=0; $i < 12; $i++) {
$sqlSatis = "SELECT sum(satisfaction) as TotalSatis FROM cbw_rating_biz WHERE business_id='$businessId' AND dateadded like '$startDate%'";
$resSatis = mysql_query($sqlSatis) or die(mysql_error());
$arrSatis = mysql_fetch_array($resSatis);
$totalSatis = $arrSatis['TotalSatis'];
$color = "00CC00"; //green
$strXML .= "<set name='" . $startDate . "' value='" . $totalSatis . "' color='" . $color ."' link='" . urlencode("histoDetail.php?businessId=" . $businessId . "&startDate=" . $startDate ) . "'/>";
$newdate = strtotime ( '+1 month' , strtotime ( $startDate ) ) ;
$startDate = date ( 'Y-m' , $newdate );
}
//Finally, close element
$strXML .= "</graph>";
//used as test to ensure that the XMl has been written
print $strXML;
//Create the chart
//Use either this
//return renderChart("cbw/swf/FCF_Line.swf", "", "", "Satisfaction", 650, 450);
// or this
return renderChart("cbw/swf/FCF_Line.swf", "", $strXML, "Satisfaction", 650, 450);
?>
-
Hi,
I am using a database query to assemble my XML statement but when I render the chart, I get a "No data to Display".
This does not work
echo renderChart("cbw/swf/FCF_Line.swf", "", $strXML, "Satisfaction", 650, 450);
The strange thing is that if I add a print $strXML just before the renderChart and capture the output from the screen and substitute $strXML in the statement with this, it works.
Works -
echo renderChart("cbw/swf/FCF_Line.swf", "", "<graph caption='Factory Output report' subCaption='By Quantity' pieSliceDepth='30' showBorder='1' showNames='1' formatNumberScale='0' numberSuffix=' Reviews' formatNumber='1' formatNumberScale='1' thousandSeparator=',' decimalPrecision='0' anchorBorderColor='0033CC' showAlternateHGridColor='1' AlternateHGridColor='ff5904' divLineColor='ff5904' divLineAlpha='20' alternateHGridAlpha='5'><set name='2008-11' value='0' color='FFE500' link='histoDetail.php%3FbusinessId%3D8%26startDate%3D2008-11'/><set name='2008-12' value='0' color='FFE500' link='histoDetail.php%3FbusinessId%3D8%26startDate%3D2008-12'/><set name='2009-01' value='0' color='FFE500' link='histoDetail.php%3FbusinessId%3D8%26startDate%3D2009-01'/><set name='2009-02' value='0' color='FFE500' link='histoDetail.php%3FbusinessId%3D8%26startDate%3D2009-02'/><set name='2009-03' value='0' color='FFE500' link='histoDetail.php%3FbusinessId%3D8%26startDate%3D2009-03'/><set name='2009-04' value='0' color='FFE500' link='histoDetail.php%3FbusinessId%3D8%26startDate%3D2009-04'/><set name='2009-05' value='0' color='FFE500' link='histoDetail.php%3FbusinessId%3D8%26startDate%3D2009-05'/><set name='2009-06' value='0' color='00CC00' link='histoDetail.php%3FbusinessId%3D8%26startDate%3D2009-06'/><set name='2009-07' value='9' color='FF0000' link='histoDetail.php%3FbusinessId%3D8%26startDate%3D2009-07'/><set name='2009-08' value='5' color='00CC00' link='histoDetail.php%3FbusinessId%3D8%26startDate%3D2009-08'/><set name='2009-09' value='20' color='FF0000' link='histoDetail.php%3FbusinessId%3D8%26startDate%3D2009-09'/><set name='2009-10' value='18' color='FF0000' link='histoDetail.php%3FbusinessId%3D8%26startDate%3D2009-10'/></graph>", "Satisfaction", 650, 450);
Piechart and MySQL
in FusionCharts and PHP
Posted · Report reply
SELECT gender, COUNT(*) AS COUNT FROM markers GROUP BY gender;