如何从fusionchart制作多线图?

时间:2014-01-28 15:29:53

标签: php linechart fusioncharts

我制作了一个php页面,其中我从数据库制作线图但我的线图未显示,我如何显示线图?这是我的代码:

  $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)
            );

1 个答案:

答案 0 :(得分:0)

set元素的语法是:

&LT; set label ='Jan'value ='10'/&gt;

在您的set元素中,您使用了两次“value”属性。因此,您无法看到单系列线2D图表。

如果要显示多系列线2D图表,则需要使用多系列图表的数据格式。请参阅:http://docs.fusioncharts.com/charts/contents/index.html?DataFormats/XML/MultiSeries.html

此外,图表类型将是MSLine。请参阅:http://docs.fusioncharts.com/charts/contents/index.html?ChartSS/MSLine.html