pChart 2.x forum http://wiki.pchart.net/forum/ |
|
Combo ScatterPlot and ScatterLine http://wiki.pchart.net/forum/viewtopic.php?f=1&t=3025 |
Page 1 of 1 |
Author: | ktyson [ Tue Apr 10, 2012 4:42 pm ] |
Post subject: | Combo ScatterPlot and ScatterLine |
I am having trouble creating a combo chart with a scatterplot of all my data and a scatterline of the averages. I can create a scatterplot of both data sets and a scatterline of both data sets but I can't seems to set one data set on each chart in the same image. Below is my code (php): Code: $DataSet = new pData(); $DataSet->addPoints($weekNum,"WeekData"); $DataSet->addPoints($yield,"YieldData"); $DataSet->addPoints($Avgyield,"AvgYieldData"); $DataSet->addPoints($AvgweekNum,"AvgWeekData"); // create scatter plot /* Create the X axis and the binded series */ $DataSet->setAxisName(0,"Week"); $DataSet->setAxisXY(0,AXIS_X); $DataSet->setAxisPosition(0,AXIS_POSITION_BOTTOM); /* Create the Y axis and the binded series */ $DataSet->setSerieOnAxis("YieldData",1); $DataSet->setAxisName(1,"Yield"); $DataSet->setAxisUnit(1,"%"); $DataSet->setAxisXY(1,AXIS_Y); $DataSet->setAxisPosition(1,AXIS_POSITION_LEFT); /* Create Avg Data */ $DataSet->setSerieOnAxis("AvgYieldData",1); $DataSet->setScatterSerie("AvgWeekData","AvgYieldData",2); $DataSet->setScatterSerieDescription(2,"Weekly Avg"); $DataSet->setScatterSerieShape(2,SERIE_SHAPE_SQUARE); $DataSet->setScatterSerieColor(2,array("R"=>255,"G"=>0,"B"=>0)); /* Create the 1st scatter chart binding */ $DataSet->setScatterSerie("WeekData","YieldData",0); $DataSet->setScatterSerieDescription(0,"Lot Avg"); $DataSet->setScatterSerieColor(0,array("R"=>0,"G"=>0,"B"=>0)); /* Create the pChart object */ $myPicture = new pImage(400,400,$DataSet); /* Draw the background */ $Settings = array("R"=>170, "G"=>183, "B"=>87, "Dash"=>1, "DashR"=>190, "DashG"=>203, "DashB"=>107); $myPicture->drawFilledRectangle(0,0,400,400,$Settings); /* Overlay with a gradient */ $Settings = array("StartR"=>219, "StartG"=>231, "StartB"=>139, "EndR"=>1, "EndG"=>138, "EndB"=>68, "Alpha"=>50); $myPicture->drawGradientArea(0,0,400,400,DIRECTION_VERTICAL,$Settings); $myPicture->drawGradientArea(0,0,400,20,DIRECTION_VERTICAL,array("StartR"=>0,"StartG"=>0,"StartB"=>0,"EndR"=>50,"EndG"=>50,"EndB"=>50,"Alpha"=>80)); /* Write the picture title */ $myPicture->setFontProperties(array("FontName"=>"Fonts/tahoma.ttf","FontSize"=>10)); $myPicture->drawText(10,16,"Title",array("R"=>255,"G"=>255,"B"=>255)); /* Add a border to the picture */ $myPicture->drawRectangle(0,0,399,399,array("R"=>0,"G"=>0,"B"=>0)); /* Set the default font */ $myPicture->setFontProperties(array("FontName"=>"Fonts/pf_arma_five.ttf","FontSize"=>10)); /* Set the graph area */ $myPicture->setGraphArea(50,50,350,350); /* Create the Scatter chart object */ $DataSet->setSerieDrawable("AvgYieldData", FALSE); $DataSet->setSerieDrawable("AvgWeekData", FALSE); $myScatter = new pScatter($myPicture,$DataSet); /* Draw the scale */ $myScatter->drawScatterScale(); /* Draw a scatter plot chart */ $myScatter->drawScatterPlotChart(); /* Draw the legend */ $myScatter->drawScatterLegend(225,390,array("Mode"=>LEGEND_HORIZONTAL,"Style"=>LEGEND_NOBORDER)); /* Draw the picture */ $myPicture->Stroke(); |
Page 1 of 1 | All times are UTC |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |