趋势线未显示在我的图表中

时间:2012-04-26 11:48:52

标签: php fusioncharts trendline

我在折线图中使用趋势线。但它在我的浏览器中不可见。任何人都可以告诉我这个的原因。下面我给出代码:

<?php
include("Includes/FusionCharts.php");
include("Includes/DBconn.php");
include("Includes/FC_Colors.php");
?>
<html>
    <title> Blood Pressure</title>
    <head>
        <script language="javascript" src="FusionCharts/FusionChart.js"></script>

    </head>
    <body>
    <center>
        <?php

        //connect to the DB
        $link= connectToDB();

        $query =  "select * from patient_health order by ondate";

        $result=mysql_query($query)or die(mysql_error());
        //echo $result;
        $strXML = "<graph caption='Blood Pressure Reading' subCaption='Month wise' xaxisname='Current Month' yaxisname='Blood Pressure(Systolic/diastole)'  yAxisMaxValue='400'
    animation='1' rotatenames='1'>";
$categories = "<categories>";
$systolic = "<dataset seriesName='systole'>";
$diaolic = "<dataset seriesName='diastole'>";
while ($row = mysql_fetch_array($result)) {
    $categories .= "<category name='" . $row["ondate"] . "' />";
    $systolic .= "<set color='AFD8F8' value='" . $row["systole_reading"] . "'  hoverText='systolic' />";
    $diaolic .= "<set value='" . $row["diastole_reading"] . "' color='FEDCBC' hoverText='diastolic'/>";
}
$strXML .= $categories . "</categories>" . $systolic . "</dataset>" . $diaolic . "</dataset>" . "</graph>";
**$strXML .=" <trendlines>
    <line startValue='140' color='91C728' displayValue='Target' showOnTop='1'/>
  </trendlines>";**
//$strXML now has the complete XML required to render the multi-series chart.

//Create the chart - Pie 3D Chart with data from $strXML
   echo renderChartHTML("FusionCharts/FCF_MSLine.swf", "", $strXML, "BloodPressure", 850, 450,false);
   //echo renderChartHTML("FusionCharts/FCF_MSBar2D.swf", "", $strXML, "BloodPressure", 850, 450,false);

       ?>

    </center>

    </body>

</html>

我是否正确放置了代码,或者我必须更改它。任何人都可以给我解决方案

提前谢谢你 Ramsai

2 个答案:

答案 0 :(得分:1)

趋势线的代码应该在关闭图元素之前,即之前 </graph>

如下所示:

}
**$strXML .=" <trendlines>
    <line startValue='140' color='91C728' displayValue='Target' showOnTop='1'/>
  </trendlines>";**
$strXML .= $categories . "</categories>" . $systolic . "</dataset>" . $diaolic . "</dataset>" . "</graph>";

这应显示您的趋势线。

答案 1 :(得分:1)

在您的代码中,您似乎在添加<graph>之前关闭了<trendlines>代码!

正确的代码是:

$strXML .= $categories . "</categories>" . $systolic . "</dataset>" . $diaolic . "</dataset>";

$strXML .=" <trendlines>
    <line startValue='140' color='91C728' displayValue='Target' showOnTop='1'/>
  </trendlines>" . "</graph>";