2

我是第一次使用 Fusion Chart。我在使用它显示数据时遇到了一些问题。即使图形得到显示,但文件中存在一些错误。

我无法检测到“通知”。请帮帮我。附加屏幕截图和代码。

    function renderChart($DB, $value, $parameter)
    {
        # Create Object of FusionCharts class

**// Error Over here**

        if ($value["chart_category"] == "S")
        {
            $FC=new FusionCharts($value["CHART_TYPE"],$value["DASHLET_WIDTH"] - 75,225,"NewChart");
        }
        else
        {
            $FC=new FusionCharts($value["CHART_TYPE"],$value["DASHLET_WIDTH"] - 75,225,"NewChart");
        }
        # set SWF Path
        $FC->setSWFPath("FusionCharts/");
        # Set Chart Parameter
        $strParam  = "caption=" . Base::replacePlaceholders($parameter, $value["DASHLET_NOTE"], false) . ";paletteThemeColor=6699FF;palette=1; animation=1;formatNumberScale=0;numberPrefix=" . $value["SERIES_PREFIX"] . ";labeldisplay=WRAP;slantLabels=1;seriesNameInToolTip=1; sNumberSuffix= pcs.;showValues=0;plotSpacePercent=0";
        # Set Chart Parameter
        $FC->setChartParams($strParam);
        # Add some styles to increase caption font size
        $FC->defineStyle("CaptionFont","font","color=black;size=10");
        $FC->defineStyle("SubCaptionFont","font","bold=0");
        # apply style to Chart�s CAPTION and SUBCAPTION
        $FC->applyStyle("caption","CaptionFont");
        $FC->applyStyle("SubCaption","SubCaptionFont");
        # Set Register With JS true
        $FC->setInitParam("registerwithjs",true);

        //Get Dashboard Query to execute
        $strSQL = Base::replacePlaceholders($parameter, $value["DASHLET_QUERY"]);

        $chartdata = $this->FetchAll($DB, $strSQL) ;

        //echo '<pre>' ;
        //print_r($chartdata) ;
        //for single series chart
        switch ($value["CHART_CATEGORY"])
        {
            case "S":
                if (count($chartdata) > 0) {
                    //Initialize datasets
                    foreach($chartdata as $key => $ors) {
                       # add chart values and  category names
                      $FC->addChartData($ors[$value["VALUE_COLUMN"]],"label=" . $ors[$value["X_AXIS_COLUMN"]]);
                    }
                }   
                break ;
            case "M":
                $strPrevCategory = "" ;
                $strSeriesValues = "" ;
                //Initialize datasets
                foreach($chartdata as $key => $ors) {
                    if ($strPrevCategory == "" OR $strPrevCategory != $ors[$value["X_AXIS_COLUMN"]]) 
                    {
                        $strCategory[] = $ors[$value["X_AXIS_COLUMN"]] ;
                        $strPrevCategory = $ors[$value["X_AXIS_COLUMN"]] ;
                    }

                    if ($strSeriesValues == "" OR strpos($strSeriesValues, "," . $ors[$value["Y_AXIS_COLUMN_1"]] . ",") === false)
                    {
                        $strSeries[] = $ors[$value["Y_AXIS_COLUMN_1"]] ;
                        $strSeriesValues = $strSeriesValues . "," . $ors[$value["Y_AXIS_COLUMN_1"]] . "," ;
                    }
                }

                foreach($strCategory as $key=>$Category)
                {
                    $FC->addCategory($Category);
                    //echo "Category ",$Category,"<br>";
                }

                foreach($strSeries as $key =>$Series)
                {
                    $FC->addDataset($Series) ;
                    //echo "Series ",$Series,"<br>" ;
                    foreach($strCategory as $key=>$Category)
                    {
                        $data = "0" ;
                        foreach($chartdata as $key => $ors) {
                            if ($Series == $ors[$value["Y_AXIS_COLUMN_1"]] AND $Category == $ors[$value["X_AXIS_COLUMN"]])
                            {
                               $data = $ors[$value["VALUE_COLUMN"]] ;
                               break ;
                            }
                        }
                        //echo "Data ",$data,"<br>" ;
                        $FC->addChartData($data) ;
                    }
                }
                break ;
            case "B":
                if ($chartdata) {
                    //Initialize datasets
                    foreach($chartdata as $key => $ors) {
                        $strCategory[] = $ors[$value["X_AXIS_COLUMN"]] ;
                        $strSeries1[] = $ors[$value["VALUE_COLUMN"]] ;
                        $strSeries2[] = $ors[$value["Y_AXIS_COLUMN_1"]] ;
                        if ($value["Y_AXIS_COLUMN_2"] != "") $strSeries3[] = $ors[$value["Y_AXIS_COLUMN_2"]] ;
                        if ($value["Y_AXIS_COLUMN_3"] != "") $strSeries4[] = $ors[$value["Y_AXIS_COLUMN_3"]] ;
                    }

                    foreach($strCategory as $Key => $Value)
                    {
                            $FC->addCategory($Value);
                    }

                    $FC->addDataset($value["VALUE_LABEL"]) ;
                    foreach($strSeries1 as $Key => $Value)
                    {
                            $FC->addChartData($Value);
                    }

                    $FC->addDataset($value["Y_AXIS_LABEL_1"]) ;
                    foreach($strSeries2 as $Key => $Value)
                    {
                            $FC->addChartData($Value);
                    }

                    if (count($strSeries3) > 0)
                    {
                        $FC->addDataset($value["Y_AXIS_LABEL_2"]) ;
                        foreach($strSeries3 as $Key => $Value)
                        {
                                $FC->addChartData($Value);
                        }
                    }

                    if (count($strSeries4) > 0)
                    {
                        $FC->addDataset($value["Y_AXIS_LABEL_3"]) ;
                        foreach($strSeries4 as $Key => $Value)
                        {
                                $FC->addChartData($Value);
                        }
                    }
                }

                break ;
            }
        $FC->renderChart(true, false);
    }
}
4

0 回答 0