Question

i make a php page in which i make line graph from database but my line graph not shown,how i show line graph?here is my code:

  $firstevent=$_POST['firstevent'];
$secondevent=$_POST['secondevent'];
$strQuery="select Distinct DATE_FORMAT(transactions.transaction_date,'%c-%d-%Y') as transaction_date,sum(amount)as Amount from transactions where event_id='".$firstevent."' group by  DATE_FORMAT(transactions.transaction_date,'%c-%d-%Y')";
    $result = mysql_query($strQuery) or die(mysql_error());
$strQuery1="select Distinct DATE_FORMAT(transactions.transaction_date,'%c-%d-%Y') as transaction_date,sum(amount)as Amount from transactions where event_id='".$secondevent."' group by  DATE_FORMAT(transactions.transaction_date,'%c-%d-%Y')";
    $result1 = mysql_query($strQuery1) or die(mysql_error());       
    $strXML = "<chart caption='Reports of transactions' showValues='0' useRoundEdges='1' palette='3'>";
    while($ors = mysql_fetch_assoc($result) or $ors1=mysql_fetch_assoc($result1)){
        print_r($ors);
        print_r($ors1);
    //Generate <set label='..' value='..' />
    $strXML .= "<set label='" .$ors['transaction_date'] ."' value='" . $ors['Amount'] ."' value='" . $ors1['Amount'] ."' />";
    }
    //free the result set
    //mysql_free_result($result);
    //mysql_close($link);
    //Finally, close <chart> element
    $strXML .= "</chart>";
    return $strXML;     
    //date_default_timezone_set($_SESSION['timezone']);
}
FC_SetRenderer('javascript');
echo renderChart('Charts/Line.swf', // Path to chart type
                '',         // Empty string when using Data String Method
                $strXML,    // Variable that contains XML string
                'Tracking', // Unique chart ID
                '850', '400', // Width and height in pixels
                false,      // Disable debug mode
                true        // Enable 'Register with JavaScript' (Recommended)
            );
Was it helpful?

Solution

The syntax of set element is :

< set label='Jan' value='10' />

In your set element, you have used the "value" attribute twice. Hence, you are not able to see the Single-series Line 2D chart.

If you want to display a Multi-series Line 2D chart, then you need to use the data format of Multi-series charts. Refer: http://docs.fusioncharts.com/charts/contents/index.html?DataFormats/XML/MultiSeries.html

Also, the chart type then would be MSLine. Refer: http://docs.fusioncharts.com/charts/contents/index.html?ChartSS/MSLine.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top