/** * Builds up the byoID chart * @param array $byoIDData recordset * @return void */ public function buildChartByMonth($byMonthData) { $technicians = array(); $MD = array(); $AP = array(); $PA = array(); foreach ($rs1->data as $k => $record) { $technicians[] = $record["Technician"]; $MD[] = $record["MD"]; $AP[] = $record["AP"]; $PA[] = $record["PA"]; } $totalcount = array_sum($MD) + array_sum($AP) + array_sum($PA); $cost = $totalcount * 35; /* Create and populate the pData object */ $chartData = $this->newData(); $chartData->addPoints($MD, "Mat. Dev."); $chartData->addPoints($AP, "An. Pro."); $chartData->addPoints($PA, "Pers. Act."); $chartData->addPoints($technicians, "Labels"); $chartData->setSerieDescription("Labels", "Technicians"); $chartData->setAbscissa("Labels"); $chartData->Antialias = true; /* Create the pChart object */ $myPicture = $this->newImage(1600, 1000, $chartData); $myPicture->setFontProperties(array("FontName" => "calibri.ttf", "FontSize" => 12)); $myPicture->drawGradientArea(0, 0, 1600, 1000, DIRECTION_VERTICAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 100)); $myPicture->drawGradientArea(0, 0, 1600, 1000, DIRECTION_HORIZONTAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 20)); /* Set the default font properties */ $myPicture->setFontProperties(array("FontName" => "verdana.ttf", "FontSize" => 10)); /* Draw the scale and the chart */ $myPicture->setGraphArea(60, 20, 1500, 800); $Settings = array("Pos" => SCALE_POS_LEFTRIGHT, "Mode" => SCALE_MODE_FLOATING, "LabelingMethod" => LABELING_ALL, "GridR" => 255, "GridG" => 255, "GridB" => 255, "GridAlpha" => 50, "TickR" => 0, "TickG" => 0, "TickB" => 0, "TickAlpha" => 50, "LabelRotation" => 90, "CycleBackground" => 1, "DrawXLines" => 1, "DrawSubTicks" => 1, "SubTickR" => 255, "SubTickG" => 0, "SubTickB" => 0, "SubTickAlpha" => 50, "DrawYLines" => ALL, "Mode" => SCALE_MODE_ADDALL_START0, "DisplayPos" => LABEL_POS_INSIDE, "DisplayValues" => true, "DisplayR" => 0, "DisplayB" => 0, "DisplayG" => 0); $myPicture->setShadow(true, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); $myPicture->drawScale($Settings); $myPicture->drawStackedBarChart(array("DisplayPos" => LABEL_POS_INSIDE, "DisplayValues" => true, "DisplayR" => 0, "DisplayB" => 0, "DisplayG" => 0, "Surrounding" => 15, "InnerSurrounding" => 15)); $myPicture->drawThreshold(168, array("Alpha" => 80, "Ticks" => 2, "R" => 0, "G" => 0, "B" => 0)); $myPicture->setFontProperties(array("FontSize" => 14)); $myPicture->drawText(100, 22, "Total Hours/Cost: " . $totalcount . " ( " . $cost . " )"); /* Write the chart legend */ $myPicture->drawLegend(1200, 10, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL)); $myPicture->render($this->PM->getProperty("basePath") . "/imagedata/lab_effort_by_month.png"); }
use Sunchemical\Suncharts\Dao\DAO; use Sunchemical\Suncharts\Charts\ChartsBuilder; use Sunchemical\Suncharts\Pdf\SunchemicalPdf; use Sunchemical\Suncharts\Response\ServiceResponse; use Sunchemical\Suncharts\Utils\Utils; use Monolog\Logger; use Monolog\Handler\RotatingFileHandler; use Monolog\Processor\IntrospectionProcessor; // # Commons Required require_once "vendor/autoload.php"; // # Create a log channel $log = new Logger('SunCharts-Sunchemical'); $log->pushHandler(new RotatingFileHandler('logs/errors', 1, Logger::ERROR)); $log->pushProcessor(new IntrospectionProcessor(Logger::ERROR)); // # Get instance and load props $PM = new PropertyManager(); // # DAOConnection instance $DAOConn = new DAOConnection($PM); // # Mailer instance $Mailer = new PHPMailer(); // # ChartsBuilder instance $CB = new ChartsBuilder($PM, $log); // # Initializing router $router = new AltoRouter(); // # This app is deployed in production as a subfolder and not a virtualhost // # so we need to set a basepath for prod environment if ($PM->getproperty('env') == 'prod') { $router->setBasePath('/suncharts/'); } // # $Params default $defaults = array('y' => date('Y'), 'm' => date('m'), 'oTypeID' => 1, 'oID' => 'All', 'techID' => 'All', 'oVendorID' => 'All', 'countryID' => 'IT');
/** * Private ( singleton ) constructor */ public function __construct(PropertyManager $PM) { $this->properties = $PM->getProperties(); $this->connect(); }