multiseries bar chart with php. Reply me!!!!
FusionCharts Forum
Home       Members    Calendar    Who's On
Welcome Guest ( Login | Register )
        



multiseries bar chart with php. Reply me!!!! Expand / Collapse
Author
Message
Posted 4/24/2008 4:40:28 AM
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: 4/29/2008 4:06:17 AM
Posts: 44, Visits: 93
Reply me please!!!!!!!!!!!! 

Above bar chart does not display data according to query result. According to your suggestion I have checked  xml file, according to that xml file it shows correct output.

But my problem is with the flag that I am using for setting the day label( means 9,11,12 in above example).Above bar chart should show day 4 before 9 & one bar of orange color on that day.But it shows that on  day '9'  instead of day '4'. This is happening because

of flag that I have used for setting day label( I am using the flag $catXMLDone that you have used in php & mysql free example multiseries example i.e. get sales by product bar chart). I am giving the following php  code. can you tell me the solution?

 $strXML = "<graph caption='Factory  Output ' subcaption='(In Units)' xAxisName='Date' formatNumberScale='0' decimalPrecision='0' palette='" . getPalette() . "' >";
 
   //To store categories - also flag to check whether category is already generated
  $catXMLDone = false;
 //Initialize XML elements
 $strCat = "<categories>";
 
 //First we need to get product type id from the database
  $strSQL = "SELECT DISTINCT(p.product_type_id) as ids FROM products as p WHERE p.product_type_id >='3' GROUP BY ids ";

 $result = mysql_query($strSQL) or die(mysql_error());
 
  //To store datasets and sets
    $strDataXML = "";
 
   if ($result)
   {
   
         while($orsCat = mysql_fetch_array($result))
      {
     
            //Add this category as dataset
            $strDataXML .= "<dataset seriesName='".$orsCat['ids']."' color='".getFCColor()."' >";

     $strSQL = "SELECT COUNT(oi.product_id) as Total,  Day(o.order_complete) as days,    p.product_type_id as typeid  FROM order_items as oi, orders as o,products as p WHERE p.product_type_id = '".$orsCat['ids']."' AND p.product_id = oi.product_id AND o.order_complete >= '2008-4-4 00:00:00' AND o.order_complete <= '2008-4-12 00:00:00' AND o.order_id = oi.order_id GROUP BY days";
     //Execute it
            $result2 = mysql_query($strSQL) or die(mysql_error());
            while($ors = mysql_fetch_array($result2))
             {
      
                     //Append <category label=''> if not already done
         
                    if (!$catXMLDone)
                    {
                   $strCat .= "<category name='" .$ors['days']. "' />";
       
                    }
                 //Append data
                   $strDataXML .= "<set value='" . $ors['Total'] . "'/>";
            }
            //Update flag that we've appended categories  
            $catXMLDone = true;
            //Clear up objects
            mysql_free_result($result2);
            //Close dataset element
            $strDataXML .= "</dataset>";
        }
    }

    //Close </categories>
 $strCat .= "</categories>";
 //Create full XML
 $strXML .= $strCat.$strDataXML;

    //Close <graph> element
    $strXML .= "</graph>";
 
    //Create the chart - Column 2D Chart with data from strXML
 echo renderChart("FusionCharts/FCF_MSColumn3D.swf", "", $strXML, "FactoryDetailed", 600, 300, false, false);

Post #5913
Posted 4/24/2008 7:15:56 AM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Moderators
Last Login: Today @ 5:38:52 AM
Posts: 884, Visits: 1,420
Hi,

Could you please send us the SQL Dump of the Database, the PHP code in a zip file so that we can check whether the SQL queries are accurate as per your requirements, whther the tables contains proper data as per your needs and then if needed modify the code to produde the desired output. I am afraid, without the SQL Dump we cant predict anything up from here.

Regards,

Sudipto Choudhury
FusionCharts Team

Post #5916
« Prev Topic | Next Topic »


Permissions Expand / Collapse

All times are GMT -7:00, Time now is 5:59pm


Execution: 0.047.