Fusioncharts Xt - 多系列线2D图

时间:2013-02-27 10:41:23

标签: php fusioncharts

我正在尝试创建此图表 http://www.fusioncharts.com/demos/gallery/#line-and-area

如果你看右边的那么第三行。 (照片9的14)。

这是我使用的代码:

$this->load->plugin( 'fusion' );  
        $FC =  FusionCharts("MSLine","620","400");  

         $strParam="palette=2;showvalues=1;numvdivlines=10;drawanchors=0;numberprefix=$;divlinealpha=30;alternatehgridalpha=20;
setadaptiveymin=1;";
           # Set chart attributes 
               $FC->setChartParams($strParam);
           # Add category names
           $FC->addCategory("2001");
           $FC->addCategory("2002");
           $FC->addCategory("2003");
           $FC->addCategory("2004");
           $FC->addCategory("2005");
           # Add category names
          # Add Multi-series  Dataset
           $FC->createMSStDataset();
           # Add Multi-series dataset with in dataset
           $FC->addMSStSubDataset("Product A", "");
            # Add set data for plotting the chart
           $FC->addChartData("30");
           $FC->addChartData("26");
           $FC->addChartData("29");
           $FC->addChartData("31");
           $FC->addChartData("34");
            $FC->createMSStDataset();
           # Add Multi-series dataset with in dataset
           $FC->addMSStSubDataset("Product B", "");
           # Add set data for plotting the chart
           $FC->addChartData("1");
           $FC->addChartData("6");
           $FC->addChartData("123");
           $FC->addChartData("4");
           $FC->addChartData("132");
                echo $FC->renderChart();

由于某种原因,我无法看到2行,我只能看到1:/ 我做错了什么?

1 个答案:

答案 0 :(得分:2)

对于MSLine图表,您需要使用addDataset代替createMSStDatasetaddMSStSubDataset

注意:$ FC-> createMSStDataset或$ FC-> addMSStSubDataset适用于MSStackedColumn2DLineDYMSStackedColumn2D图表。

因此,您的代码将是:

       $this->load->plugin( 'fusion' );  
       $FC =  FusionCharts("MSLine","620","400");  

       $strParam="palette=2;showvalues=1;numvdivlines=10;drawanchors=0;numberprefix=$;divlinealpha=30;alternatehgridalpha=20;setadaptiveymin=1;";

       # Set chart attributes 
       $FC->setChartParams($strParam);
       # Add category names
       $FC->addCategory("2001");
       $FC->addCategory("2002");
       $FC->addCategory("2003");
       $FC->addCategory("2004");
       $FC->addCategory("2005");
       $FC->addDataset("Product A", "");
        # Add set data for plotting the chart
       $FC->addChartData("30");
       $FC->addChartData("26");
       $FC->addChartData("29");
       $FC->addChartData("31");
       $FC->addChartData("34");

       $FC->addDataset("Product B", "");
       # Add set data for plotting the chart
       $FC->addChartData("1");
       $FC->addChartData("6");
       $FC->addChartData("123");
       $FC->addChartData("4");
       $FC->addChartData("132");
       echo $FC->renderChart();

参考:http://docs.fusioncharts.com/charts/?guide-for-web-developers/fusioncharts-php-class/MultiSeriesChart.html