Ejemplo n.º 1
0
 /**
  * Series output
  */
 public function testData()
 {
     $chart = new Highchart();
     $chart->series($this->series);
     $this->assertRegExp('/\\{"name":"Data Serie #1","data":\\[1,2,4,5,6,3,8\\]\\}/', $chart->render());
     $this->assertRegExp('/\\{"name":"Data Serie #2","data":\\[7,3,5,1,6,5,9\\]\\}/', $chart->render());
 }
Ejemplo n.º 2
0
 public function chartAction($pk)
 {
     $Project = $this->getObject($pk);
     $this->checkCredentials($Project);
     if (!$Project) {
         throw new NotFoundHttpException("The Taskeet\\MainBundle\\Entity\\Project with id {$pk} can't be found");
     }
     $ob = new Highchart();
     $ob->chart->renderTo($Project->getName());
     $ob->title->text($Project->getName());
     $ob->plotOptions->pie(array('allowPointSelect' => true, 'cursor' => 'pointer', 'dataLabels' => array('enabled' => false), 'showInLegend' => true));
     $data = array();
     $datag = array();
     foreach ($Project->getTickets() as $task) {
         if (array_key_exists($task->getStatus()->getName(), $data)) {
             $data[$task->getStatus()->getName()] = $data[$task->getStatus()->getName()] + 1;
         } else {
             $data[$task->getStatus()->getName()] = +1;
         }
     }
     foreach ($data as $key => $value) {
         $datag[] = array($key, $value);
     }
     $ob->series(array(array('type' => 'pie', 'name' => 'Estado de las tareas', 'data' => $datag)));
     return $this->render('TaskeetMainBundle:ProjectShow:chart.html.twig', $this->getAdditionalRenderParameters($Project) + array("Project" => $Project, 'chart' => $ob));
 }
Ejemplo n.º 3
0
 /**
  * @Route("/stationstate/{stationId}", requirements={"stationId"="\d+"}, name="station_state_graph")
  * @Method("GET")
  * @Template()
  */
 public function chartAction($stationId)
 {
     $stationRepository = $this->getDoctrine()->getRepository('StationMapping:Station');
     /**
      * @var Station $station
      */
     $station = $stationRepository->findOneById($stationId);
     $startingTime = time() - 86400;
     $availableBikes = [];
     foreach ($station->getStationStates() as $stationState) {
         $stationStateTime = $stationState->getTime()->getTimestamp();
         if ($stationStateTime >= $startingTime) {
             // this needs to be optimized
             $relativeTimeOfTheDayInHours = ($stationStateTime - $startingTime) / 3600;
             // this is not really the relative time of the day, need to calculate properly
             $availableBikes[] = [$relativeTimeOfTheDayInHours, $stationState->getAvailableBikes()];
         }
     }
     $availableBikes[] = [(time() - $startingTime) / 3600, $station->getCurrentStationState()->getAvailableBikes()];
     $series = array(array("name" => sprintf('Available bikes for %d', $stationId), 'data' => $availableBikes));
     $chart = new Highchart();
     $chart->chart->renderTo('linechart');
     // The #id of the div where to render the chart
     $chart->title->text('Chart Title');
     $chart->xAxis->title(array('text' => "Horizontal axis title"));
     $chart->yAxis->title(array('text' => "Vertical axis title"));
     $chart->series($series);
     return array('chart' => $chart);
 }
Ejemplo n.º 4
0
 /**
  * Series output
  */
 public function testColors()
 {
     $linechart = new Highchart();
     $colors = array('#FF0000', '#00FF00', '#0000FF');
     $linechart->colors($colors);
     $this->assertRegExp('/colors: \\[\\["#FF0000","#00FF00","#0000FF"\\]\\]/', $linechart->render());
 }
 public function findForPage($page_id)
 {
     $data = self::findBy(['page' => $page_id]);
     $ret = [];
     foreach ($data as $element) {
         $id = $element->getId();
         $backgroundColor = self::hex2rgba($element->getBackgroundColor(), $element->getBackgroundOpacity());
         $chart = new Highchart();
         $chart->global->useUTC(false);
         $chart->chart->animation(false)->renderTo('chart_' . $id)->backgroundColor($backgroundColor)->height($element->getHeight())->margin([2, 2, 2, 2]);
         $chart->title->text(null);
         $chart->xAxis->title(null)->type('datetime')->visible(false);
         $chart->yAxis->title(null)->visible(true)->minorTickColor('transparent')->minorGridLineColor('transparent')->gridLineColor('transparent')->lineColor('transparent')->plotLines([['value' => $element->getConst(), 'color' => $element->getConstColor(), 'width' => 1]]);
         $chart->exporting->enabled(false);
         $chart->legend->enabled(false);
         $chart->credits->enabled(false);
         $chart->tooltip->enabled(false);
         $chart->plotOptions->series(['lineWidth' => 1, 'marker' => ['enabled' => false], 'enableMouseTracking' => false]);
         $from = (new \DateTime())->modify("-" . $element->getHourOffset() . " hour");
         $registerArchiveData = self::getArchiveData($from, $element->getSource()->getId());
         $arrayToChart = array();
         foreach ($registerArchiveData as $rad) {
             $time = $rad["timeOfInsert"]->getTimestamp() * 1000;
             array_push($arrayToChart, [$time, $rad["fixedValue"]]);
         }
         $series = ['data' => $arrayToChart, 'color' => $element->getColor()];
         $chart->series([$series]);
         $ret[$id] = $chart;
     }
     return $ret;
 }
Ejemplo n.º 6
0
 public function PieAction()
 {
     $ob = new Highchart();
     $ob->chart->renderTo('piechart');
     $ob->title->text('Nombre des utilisateurs ');
     $ob->plotOptions->pie(array('allowPointSelect' => true, 'cursor' => 'pointer', 'dataLabels' => array('enabled' => false), 'showInLegend' => true));
     $em = $this->getDoctrine()->getManager();
     $query = $em->createQuery('SELECT count(et.id)
              FROM MyAppGrapheBundle:Administrateur et');
     $Administrateur = $query->getSingleScalarResult();
     $et = (int) $Administrateur;
     $em1 = $this->getDoctrine()->getManager();
     $query1 = $em1->createQuery('SELECT count(en.sexe)
              FROM MyAppGrapheBundle:Client en');
     $Client = $query1->getSingleScalarResult();
     $en = (int) $Client;
     $em3 = $this->getDoctrine()->getManager();
     $query3 = $em3->createQuery('SELECT count(en2.nbreboutique)
              FROM MyAppGrapheBundle:Mall en2');
     $Mall = $query3->getSingleScalarResult();
     $en2 = (int) $Mall;
     $em4 = $this->getDoctrine()->getManager();
     $query4 = $em4->createQuery('SELECT count(en3.nbreenseigne)
              FROM MyAppGrapheBundle:Mall en3');
     $mall = $query4->getSingleScalarResult();
     $en3 = (int) $mall;
     $data = array(array('Administrateur', $et), array('Client', $en), array('Mall', $en2), array('Mall', $en3));
     $ob->series(array(array('type' => 'pie', 'name' => 'Browser share', 'data' => $data)));
     return $this->render('MyAppGrapheBundle:Graphe:pie.html.twig', array('chart' => $ob));
 }
Ejemplo n.º 7
0
 /**
  * Enabled option (true/false)
  */
 public function testEnabledDisabled()
 {
     $chart = new Highchart();
     $chart->legend->enabled(false);
     $this->assertRegExp('/legend: \\{"enabled":false\\}/', $chart->render());
     $chart->legend->enabled(true);
     $this->assertRegExp('/legend: \\{"enabled":true\\}/', $chart->render());
 }
Ejemplo n.º 8
0
 /**
  * useUTC option (true/false)
  */
 public function testGlobal()
 {
     $chart = new Highchart();
     $chart->global->useUTC("true");
     $this->assertRegExp('/global: \\{"useUTC":"true"\\}/', $chart->render());
     $chart->global->useUTC("false");
     $this->assertRegExp('/global: \\{"useUTC":"false"\\}/', $chart->render());
 }
    /**
     * @Route("", name="landing")
     * @Template("ReportsBundle:Default:index.html.twig")
     */
    public function indexAction()
    {
        $data = array();
        $bigDataArray = array();
        $closedTickets = $this->get('doctrine')->getEntityManager('ost')->createQuery("SELECT ostt FROM ReportsBundle:ost_ticket ostt WHERE ostt.statusid = 2 or ostt.statusid = 3")->getResult();
        $num = count($closedTickets);
        $data['total_closed_tickets'] = $num;
        $query = $this->get('doctrine')->getEntityManager('ost')->createQuery("SELECT ostt FROM ReportsBundle:ost_ticket ostt WHERE ostt.statusid = 1")->getResult();
        $num = count($query);
        $data['total_open_tickets'] = $num;
        //Grab start date
        $startDateInSeries = $closedTickets[0]->getClosed();
        // Grab last date
        $endDateInSeries = $closedTickets[$data['total_closed_tickets'] - 1]->getClosed();
        $yourController = $this->get('adminService');
        $bigDataArray = $yourController->__getTimeSeriesFromDates($startDateInSeries, $endDateInSeries, $closedTickets);
        $series = array(array("name" => "Data Series Name", "data" => $bigDataArray, "type" => "area"));
        $func = new Expr('function(e) {
                    var id = $("#linechart").attr("data-id");
                    
                    $.ajax({
                        type: "POST",
                        url: "/ticketlookup",
                        data: {
                           id: id,
                           startDate: e.min,
                           endDate: e.max,
                    },
                    dataType: "json",
                    
                    success: function(response) 
                    {
                        $("#response").children().remove();
                        if(response.total_response != 0)
                        {
                            $("#response").append("<p>Total number of tickets: "+response.total_response);
                            $("#response").append(response.table);
                        }
                    }
                    });

                    }');
        $ob = new Highchart();
        $ob->chart->renderTo('linechart');
        // The #id of the div where to render the chart
        $ob->chart->zoomType('x');
        $ob->legend->enabled(false);
        $ob->title->text('Timeseries of closed tickets');
        $ob->xAxis->title(array('text' => "Dates"));
        $ob->xAxis->events(array('setExtremes' => $func));
        $ob->xAxis->type('datetime');
        //$ob->xAxis->tickInterval((24 * 3600 * 1000 * 10));
        $ob->yAxis->title(array('text' => "Freq of closed tickets"));
        $ob->yAxis->type(array('number'));
        $ob->plotOptions->line(array('dataLabels' => array('enabled' => true)));
        $ob->series($series);
        return array('data' => $data, 'chart' => $ob);
    }
Ejemplo n.º 10
0
 public function newPieChart($series)
 {
     $ob = new Highchart();
     $ob->plotOptions->pie(array('allowPointSelect' => true, 'cursor' => 'pointer', 'showInLegend' => true, 'dataLabels' => array('enabled' => false)));
     $ob->series($series);
     $ob->title->style(array('fontWeight' => 'bold', 'fontSize' => '20px'));
     $ob->credits->enabled(false);
     $ob->title->text('Répartition des dépenses selon les comptes comptables (Mandat en cours)');
     $ob->tooltip->pointFormat('{point.percentage:.1f} %');
     return $ob;
 }
Ejemplo n.º 11
0
 public function createConfiguration(array $addedVocabularyData, array $learnedVocabularyData, Date $startDate, $chartId)
 {
     $series = array(array('name' => 'Added vocabulary', 'data' => $addedVocabularyData, 'color' => '#5D6FE3', 'pointStart' => new Expr('Date.UTC(' . $startDate->getYear() . ', ' . $startDate->getMonth() . ', ' . $startDate->getDay() . ')'), 'pointInterval' => new Expr('24 * 3600 * 1000')), array('name' => 'Learned vocabulary', 'data' => $learnedVocabularyData, 'color' => '#5DB83D', 'pointStart' => new Expr('Date.UTC(' . $startDate->getYear() . ', ' . $startDate->getMonth() . ', ' . $startDate->getDay() . ')'), 'pointInterval' => new Expr('24 * 3600 * 1000')));
     $ob = new Highchart();
     $ob->chart->renderTo($chartId);
     $ob->title->text('Vocabulary');
     $ob->xAxis->type('datetime');
     $ob->exporting->enabled(false);
     $ob->series($series);
     return $ob;
 }
Ejemplo n.º 12
0
 public function getChart()
 {
     $ob = new Highchart();
     $ob->chart->renderTo('linechart');
     $ob->title->text('History data for your portfolio');
     $ob->xAxis->title(['text' => "Time"]);
     $ob->xAxis->categories($this->xAxisPoints);
     $ob->yAxis->title(['text' => "Price"]);
     $ob->series($this->series);
     return $ob;
 }
Ejemplo n.º 13
0
 public function buildChart($data)
 {
     $series = [['name' => 'Total tasks', 'data' => [$data['all']]], ['name' => 'Completed', 'data' => [$data['completed']]], ['name' => 'Completed on-time', 'data' => [$data['completed_ontime']]], ['name' => 'Completed overdue', 'data' => [$data['completed_overdue']]], ['name' => 'Pending', 'data' => [$data['pending']]], ['name' => 'Pending on-time', 'data' => [$data['pending_ontime']]], ['name' => 'Pending overdue', 'data' => [$data['pending_overdue']]]];
     $ob = new Highchart();
     $ob->chart->renderTo('stat-charts');
     // The #id of the div where to render the chart
     $ob->chart->type('column');
     $ob->title->text('Task Statistics');
     $ob->xAxis->title(['text' => "Parameter"]);
     $ob->yAxis->title(['text' => "Value"]);
     $ob->series($series);
     return $ob;
 }
Ejemplo n.º 14
0
 public function indexAction()
 {
     // Chart
     $series = array(array("name" => "Data Serie Name", "data" => array(1, 2, 4, 5, 6, 3, 8)));
     $ob = new Highchart();
     $ob->chart->renderTo('linechart');
     // The #id of the div where to render the chart
     $ob->title->text('Chart Title');
     $ob->xAxis->title(array('text' => "Horizontal axis title"));
     $ob->yAxis->title(array('text' => "Vertical axis title"));
     $ob->series($series);
     return $this->render('test.html.twig', array('chart' => $ob));
 }
Ejemplo n.º 15
0
 public function chartAction()
 {
     // Chart
     $series = array(array("name" => "Data Serie Name", "data" => array(1, 2, 4, 5, 6, 3, 8)));
     $ob = new Highchart();
     $ob->chart->renderTo('linechart');
     // The #id of the div where to render the chart
     $ob->title->text('nombre d utilisateur connecte');
     $ob->xAxis->title(array('text' => "date"));
     $ob->yAxis->title(array('text' => "utilisateur Connecte"));
     $ob->series($series);
     return $this->render('utilisateurBundle:Default:statistique.html.twig', array('chart' => $ob));
 }
Ejemplo n.º 16
0
 /**
  * @param string $command
  * @param string $category
  * @param array $logs
  *
  * @return Highchart
  */
 public static function get($command, $category, array $logs)
 {
     $series = array(array("name" => sprintf("%s - %s statistics", $command, ucfirst($category)), "data" => array_values($logs)));
     $ob = new Highchart();
     $ob->chart->renderTo('linechart');
     // The #id of the div where to render the chart
     $ob->title->text('Chart Title');
     $ob->xAxis->title(array('text' => "Date and time"));
     $ob->xAxis->categories(array_keys($logs));
     $ob->yAxis->title(array('text' => sprintf("%s (in %s)", ucfirst($category), Parser::getCategoryUnit($category))));
     $ob->series($series);
     return $ob;
 }
Ejemplo n.º 17
0
 /**
  * @Route("/", name="dashboard")
  * @Template()
  */
 public function indexAction()
 {
     $linechart = new Widget('Line Chart', 'linechart');
     $series = array(array("name" => "Data Serie Name", "data" => array(1, 2, 4, 5, 6, 3, 8)));
     $ob = new Highchart();
     $ob->chart->renderTo('linechart');
     // The #id of the div where to render the chart
     $ob->title->text('Chart Title');
     $ob->xAxis->title(array('text' => "Horizontal axis title"));
     $ob->yAxis->title(array('text' => "Vertical axis title"));
     $ob->series($series);
     $linechart->setChartData($ob);
     $widgets = array($linechart);
     return array("widgets" => $widgets);
 }
Ejemplo n.º 18
0
 /**
  * Scrollbar config output
  */
 public function testConfig()
 {
     $chart = new Highchart();
     foreach ($this->scrollbar as $key => $value) {
         // Config randomization
         if (mt_rand(0, 5) === 0) {
             continue;
         }
         $this->usedOptions[$key] = $value;
         $chart->scrollbar->{$key}($value);
     }
     preg_match('|scrollbar: (\\{[^\\}]+\\})+|', $chart->render(), $matches);
     $options = json_decode($matches[1], true);
     $this->assertEquals(count($this->usedOptions), count(array_intersect($this->usedOptions, $options)));
 }
Ejemplo n.º 19
0
 public function execute(BlockContextInterface $block, Response $response = null)
 {
     // merge settings
     $settings = array_merge($this->getDefaultSettings(), $block->getSettings());
     // Get validated hours per week
     $query = $this->em->createQuery("SELECT\n          SUM(HOUR(c.duration) + MINUTE(c.duration)/60) AS time,\n          YEAR(c.date) AS year,\n          WEEK(c.date) AS week\n          FROM MathsupCouponBundle:Course c\n          GROUP BY year, week\n          ORDER BY year, week DESC\n          ");
     $hoursPerWeek = $query->getArrayResult();
     $hoursPerWeekData = [];
     foreach ($hoursPerWeek as $week) {
         $week_start = new \DateTime();
         $week_start->setISODate($week['year'], $week['week']);
         $hoursPerWeekData[] = array('name' => $week_start->format('d-M-Y'), 'x' => $week_start->getTimestamp() * 1000, 'y' => (int) $week['time']);
     }
     $query = $this->em->createQuery("\n          SELECT\n              COUNT(s) AS n,\n              YEAR(s.createdAt) AS year,\n              MONTH(s.createdAt) AS month,\n              DAY(s.createdAt) AS day,\n              s.createdAt AS date\n          FROM MathsupUserBundle:Student s\n          GROUP BY year, month, day\n          ORDER BY s.createdAt ASC\n          ");
     $studentCountEvolution = $query->getResult();
     $studentCountEvolutionData = [];
     $studentCount = 0;
     foreach ($studentCountEvolution as $day) {
         $studentCount += $day['n'];
         $studentCountEvolutionData[] = array('name' => $day['date']->format('d-M-Y'), 'y' => (int) $studentCount, 'x' => $day['date']->getTimestamp() * 1000);
     }
     $hoursPerWeekChart = new Highchart();
     $hoursPerWeekChart->title->text('Heures de cours validées par semaine');
     $hoursPerWeekChart->chart->renderTo('hours_per_week_chart');
     $hoursPerWeekChart->chart->zoomType('x');
     $hoursPerWeekChart->xAxis->title(array('text' => "Semaine"));
     $hoursPerWeekChart->xAxis->type('datetime');
     $hoursPerWeekChart->yAxis(array(array("title" => array('text' => "Heures")), array("title" => array('text' => "Nombre d'étudiants"), "opposite" => true)));
     $series = array(array("name" => "Nombre d'heure", "type" => "column", "data" => $hoursPerWeekData), array("name" => "Nombre d'étudiants", "data" => $studentCountEvolutionData, "step" => true, "yAxis" => 1));
     $hoursPerWeekChart->series($series);
     $qb = $this->em->createQueryBuilder();
     $qb->select($qb->expr()->count('s'))->from('MathsupUserBundle:Student', 's')->where('s.enabled = true');
     $studentCount = $qb->getQuery()->getSingleScalarResult();
     // get professor count
     $qb = $this->em->createQueryBuilder();
     $qb->select($qb->expr()->count('p'))->from('MathsupUserBundle:Professor', 'p')->where('p.enabled = true');
     $professorCount = $qb->getQuery()->getSingleScalarResult();
     // Create user number (and repartition) pie chart
     $usersChart = new Highchart();
     $usersChart->title->text('Utilisateurs');
     $usersChart->chart->renderTo('users_chart');
     $usersChart->chart->type('pie');
     $usersChart->plotOptions->pie(array('allowPointSelect' => true, 'cursor' => 'pointer', 'dataLabels' => array('enabled' => true, 'format' => '<b>{point.name}</b>: {point.y}')));
     $usersChart->series(array(array('name' => 'Utilisateurs', 'colorByPoint' => 'true', 'data' => array(array('name' => 'Étudiants', 'y' => (int) $studentCount), array('name' => 'Professeurs', 'y' => (int) $professorCount)))));
     return $this->renderResponse($block->getTemplate(), array('hours_per_week_chart' => $hoursPerWeekChart, 'student_count_evolution' => $studentCountEvolutionData, 'users_chart' => $usersChart, 'block' => $block->getBlock(), 'settings' => $settings), $response);
 }
Ejemplo n.º 20
0
 public function getSimplyCharts(Session $session, $questions)
 {
     $charts = array();
     foreach ($questions as $question) {
         $chartName = 'questionChart' . $question->getId();
         $answers = $this->manager->getRepository('SurveyBundle:Answer')->findBy(array('session' => $session, 'question' => $question));
         $series = array(array('type' => 'column', "name" => 'Votes', "data" => $this->getSerieData($question, $answers)));
         $ob = new Highchart();
         $ob->chart->renderTo($chartName);
         // The #id of the div where to render the chart
         $ob->title->text($question->getTitle());
         $ob->xAxis->title(array('text' => $question->getScale()->getLeftLabel() . ' - ' . $question->getScale()->getRightLabel()));
         $ob->xAxis->categories(array_fill(0, $question->getScale()->getSize(), ''));
         $ob->series($series);
         $charts[$chartName] = $ob;
     }
     return $charts;
 }
Ejemplo n.º 21
0
 /**
  * @Route("/{cid}ver/{caid}")
  * @Template()
  */
 public function verAction($cid, $caid)
 {
     $em = $this->getDoctrine()->getManager();
     $carrera = $em->getRepository('UmgVotacionBundle:CampusCarrera')->find($caid);
     $catedratico = $em->getRepository('UmgVotacionBundle:Catedratico')->find($cid);
     $cursos = $em->getRepository('UmgVotacionBundle:CarreraCurso')->findCursos($carrera, $catedratico);
     $promedio = $em->getRepository('UmgVotacionBundle:CampusCarrera')->findPunteoCatedraticoCarrera($catedratico, $carrera);
     $datos = array();
     foreach ($promedio as $prom) {
         $datos[] = floatval($prom['calificacion']);
     }
     $series = array(array("name" => "Data Serie Name", "data" => $datos));
     $ob = new Highchart();
     $ob->chart->renderTo('linechart');
     // The #id of the div where to render the chart
     $ob->title->text('Chart Title');
     $ob->xAxis->title(array('text' => "Promedios"));
     $ob->yAxis->title(array('text' => "Evaluaciones"));
     $ob->series($series);
     return array('chart' => $ob, 'catedratico' => $catedratico, 'cursos' => $cursos);
 }
Ejemplo n.º 22
0
 public function chartAction()
 {
     $User = $this->getUser();
     $ob = new Highchart();
     $ob->chart->renderTo($User->getUsername());
     $ob->title->text($User->getUsername());
     $ob->plotOptions->pie(array('allowPointSelect' => true, 'cursor' => 'pointer', 'dataLabels' => array('enabled' => false), 'showInLegend' => true));
     $data = array();
     $datag = array();
     foreach ($User->getTasks() as $task) {
         if (array_key_exists($task->getStatus()->getName(), $data)) {
             $data[$task->getStatus()->getName()] = $data[$task->getStatus()->getName()] + 1;
         } else {
             $data[$task->getStatus()->getName()] = +1;
         }
     }
     foreach ($data as $key => $value) {
         $datag[] = array($key, $value);
     }
     $ob->series(array(array('type' => 'pie', 'name' => 'Estado de las tareas', 'data' => $datag)));
     return $this->render('TaskeetMainBundle:UserShow:chart.html.twig', array("User" => $User, 'chart' => $ob));
 }
Ejemplo n.º 23
0
 private function daychart($date)
 {
     $pgcod = $this->container->getParameter('cod.saleclose');
     $repository = $this->getDoctrine()->getRepository('UerpSaleBundle:Sale');
     $query = $repository->createQueryBuilder('b')->addselect('SUM(b.totalsale) as sumtotal')->where('b.date >= :datei AND b.date <= :datef AND b.status = :codpg ')->setParameters(array('datei' => $date, 'datef' => $date, 'codpg' => $pgcod))->groupBy('b.seller')->getQuery();
     $ob = new Highchart();
     $ob->chart->renderTo('piechart');
     $ob->plotOptions->pie(array('allowPointSelect' => true, 'cursor' => 'pointer', 'dataLabels' => array('enabled' => true)));
     $data = array();
     $em = $this->getDoctrine()->getManager();
     $t = 0.0;
     $entities = $query->getResult();
     foreach ($entities as $sale) {
         $entitya = $em->getRepository('UerpSellerBundle:Seller')->find($sale[0]->getseller()->getId());
         $sellername = $entitya->getName();
         $t += floatval($sale['sumtotal']);
         $data[] = array($sellername, floatval($sale['sumtotal']));
     }
     $ob->title->text($this->get('translator')->trans('day_sales'));
     $ob->series(array(array('type' => 'pie', 'name' => 'Day sales', 'data' => $data)));
     return $ob;
 }
Ejemplo n.º 24
0
 /**
  * width option (integer - width in px)
  */
 public function testWidth()
 {
     $chart = new Highchart();
     $chart->exporting->width(300);
     $this->assertRegExp('/exporting: \\{"width":300\\}/', $chart->render());
 }
 /**
  * @param $averageWeight
  * @param $averageBodyFat
  * @param $averageMuscleMass
  * @param $roundedCombinedRange
  * @param $roundedWeightRange
  *
  * @return Highchart
  */
 private function _populateNewChart($averageWeight, $averageBodyFat, $averageMuscleMass, $roundedCombinedRange, $roundedWeightRange, $time)
 {
     $chart = new Highchart();
     $series = array(array('name' => $this->_trans(StatisticEntry::WEIGHT), 'type' => 'column', 'color' => '#4572A7', 'yAxis' => 1, 'data' => array_values($averageWeight)), array('name' => $this->_trans(StatisticEntry::BODY_FAT), 'type' => 'spline', 'color' => '#AA4643', 'data' => array_values($averageBodyFat)), array('name' => $this->_trans(StatisticEntry::MUSCLE_MASS), 'type' => 'spline', 'color' => '#FAB048', 'data' => array_values($averageMuscleMass)));
     $yData = array(array('labels' => array('formatter' => new Expr('function () { return this.value + " ' . $this->_trans('Percent') . '" }'), 'style' => array('color' => '#AA4643')), 'title' => array('text' => $this->_trans('Body Fat') . ' / ' . $this->_trans('Muscle Mass'), 'style' => array('color' => '#AA4643')), 'opposite' => true, 'min' => $roundedCombinedRange[0], 'max' => $roundedCombinedRange[1], 'maxPadding' => 0, 'minPadding' => 0, 'tickInterval' => 5, 'tickAmount' => ($roundedCombinedRange[1] - $roundedCombinedRange[0]) / 5 + 1), array('labels' => array('formatter' => new Expr('function () { return this.value + " kg" }'), 'style' => array('color' => '#4572A7')), 'title' => array('text' => $this->_trans(StatisticEntry::WEIGHT), 'style' => array('color' => '#4572A7')), 'tickInterval' => 5, 'min' => $roundedWeightRange[0], 'tickAmount' => ($roundedWeightRange[1] - $roundedWeightRange[0]) / 5 + 1, 'endOnTick' => false, 'gridLineWidth' => 2, 'max' => $roundedWeightRange[1], 'maxPadding' => 0, 'minPadding' => 0));
     $chart->yAxis($yData);
     $chart->chart->type('column');
     $chart->chart->backgroundColor('rgba(255, 255, 255, 0.7)');
     $chart->title->text($this->_trans('profile.chart.weight.headline'));
     $chart->xAxis->categories($time);
     $chart->legend->enabled(false);
     $formatter = new Expr('function () {
              var unit = {
                  "' . $this->_trans('Weight') . '": " kg",
                  "' . $this->_trans('Body Fat') . '": "' . $this->_trans('Body Fat') . ' %",
                  "' . $this->_trans('Muscle Mass') . '": "' . $this->_trans('Muscle Mass') . ' %"
              }[this.series.name];
              return this.x + ": <b>" + this.y + "</b> " + unit;
          }');
     $chart->tooltip->formatter($formatter);
     $chart->series($series);
     return $chart;
 }
Ejemplo n.º 26
0
 public function graphiqueSalaire()
 {
     for ($an = date('Y') - 10; $an <= date('Y'); $an++) {
         $annees[] = $an;
         $querySalaire = $this->getDoctrine()->getRepository('AMiEMiagistesBundle:Formulaire')->searchSalaire($an);
         $moyenne[] = (int) $querySalaire->getSingleScalarResult();
         // retourne un seul résultat en string qu'on caste en int
     }
     $graph = new Highchart();
     $graph->chart->renderTo('splineSalaire');
     $graph->title->text('Evolution du salaire brut annuel moyen prévu par années');
     $graph->chart->type('spline');
     $series[0]['name'] = 'Salaire moyen';
     $series[0]['type'] = 'spline';
     for ($i = 0; $i < sizeof($moyenne); $i++) {
         $series[0]['data'][] = $moyenne[$i];
     }
     $yData = array(array('title' => array('text' => "Salaire moyen (brut)")));
     $graph->yAxis($yData);
     $graph->xAxis->title(array('text' => "Années"));
     $graph->xAxis->categories($annees);
     $graph->series($series);
     return $graph;
 }
Ejemplo n.º 27
0
 public function testStartAngle()
 {
     $chart = new Highchart();
     $chart->pane->startAngle(5);
     $this->assertRegExp('/pane: \\{"startAngle":5\\}/', $chart->render());
 }
    /**
     * Generate aggregated reports
     *
     * @Secure(roles="ROLE_SUPER_USER,ROLE_REPORTHISTORY_GENERATE")
     * @Route("/", name="report_historytraining_generate")
     * @Method("PUT")
     * @Template()
     */
    public function generateAction(Request $request)
    {
        $historytrainingForm = $this->createForm(new ReportHistoryTrainingType($this->getUser()), null, array('em' => $this->getDoctrine()->getManager()));
        $historytrainingForm->bind($request);
        if ($historytrainingForm->isValid()) {
            $historytrainingFormData = $historytrainingForm->getData();
            $organisationUnit = $historytrainingFormData['organisationunit'];
            $forms = $historytrainingFormData['forms'];
            $reportType = $historytrainingFormData['reportType'];
            $withLowerLevels = $historytrainingFormData['withLowerLevels'];
            $fields = $historytrainingFormData['fields'];
            $graphType = $historytrainingFormData['graphType'];
        }
        //Create fields object is not passed from form
        if (is_null($fields)) {
            $fields = new Field();
        }
        $results = $this->aggregationEngine($organisationUnit, $forms, $fields, $reportType, $withLowerLevels);
        //Get the Id for the form
        $formsId = $forms->getId();
        //If training report generation
        if ($reportType == "training") {
            foreach ($results as $result) {
                $categories[] = $result['data'];
                $data[] = $result['total'];
                if ($graphType == 'pie') {
                    $piedata[] = array('name' => $result['data'], 'y' => $result['total']);
                }
            }
            if ($graphType == 'pie') {
                $data = $piedata;
            }
            $series = array(array('name' => "Trainings", 'data' => $data));
            if ($withLowerLevels) {
                $withLower = " with lower levels";
            }
            $formatterLabel = 'Trainings';
            $subtitle = "Trainings";
        } else {
            if ($reportType == "history") {
                foreach ($results as $result) {
                    $categories[] = $result['data'];
                    $data[] = $result['total'];
                    if ($graphType == 'pie') {
                        $piedata[] = array('name' => $result['data'], 'y' => $result['total']);
                    }
                }
                if ($graphType == 'pie') {
                    $data = $piedata;
                }
                $series = array(array('name' => $fields->getCaption(), 'data' => $data));
                if ($withLowerLevels) {
                    $withLower = " with lower levels";
                }
                $formatterLabel = $fields->getCaption();
                $subtitle = $fields->getCaption() . " History";
            }
        }
        //check which type of chart to display
        if ($graphType == "bar") {
            $graph = "column";
        } elseif ($graphType == "line") {
            $graph = "spline";
        } else {
            $graph = "pie";
        }
        //set the title and sub title
        $title = $subtitle . " Distribution Report";
        /*
                return array(
                    'organisationunit' => $organisationunit,
                    'forms'   => $forms,
                    'fields' => $fields,
                );*/
        $yData = array(array('labels' => array('formatter' => new Expr('function () { return this.value + "" }'), 'style' => array('color' => '#0D0DC1')), 'title' => array('text' => $subtitle, 'style' => array('color' => '#0D0DC1')), 'opposite' => true), array('labels' => array('formatter' => new Expr('function () { return this.value + "" }'), 'style' => array('color' => '#AA4643')), 'gridLineWidth' => 1, 'title' => array('text' => $subtitle, 'style' => array('color' => '#AA4643'))));
        $dashboardchart = new Highchart();
        $dashboardchart->chart->renderTo('chart_placeholder_historytraining');
        // The #id of the div where to render the chart
        $dashboardchart->chart->type($graph);
        $dashboardchart->title->text($title);
        $dashboardchart->subtitle->text($organisationUnit->getLongname() . $withLower);
        $dashboardchart->xAxis->categories($categories);
        $dashboardchart->yAxis($yData);
        $dashboardchart->legend->enabled(true);
        $formatter = new Expr('function () {
                 var unit = {

                     "' . $formatterLabel . '" : "' . strtolower($formatterLabel) . '",

                 }[this.series.name];
                 if(this.point.name) {
                    return ""+this.point.name+": <b>"+ this.y+"</b> "+ this.series.name;
                 }else {
                    return this.x + ": <b>" + this.y + "</b> " + this.series.name;
                 }
             }');
        $dashboardchart->tooltip->formatter($formatter);
        if ($graphType == 'pie') {
            $dashboardchart->plotOptions->pie(array('allowPointSelect' => true, 'dataLabels' => array('format' => '<b>{point.name}</b>: {point.percentage:.1f} %')));
        }
        $dashboardchart->series($series);
        return array('chart' => $dashboardchart, 'data' => $data, 'categories' => $categories, 'organisationUnit' => $organisationUnit, 'formsId' => $formsId, 'reportType' => $reportType, 'withLowerLevels' => $withLowerLevels, 'fields' => $fields, 'title' => $title);
    }
Ejemplo n.º 29
0
 /**
  * Graph/Simulate Payment Deferrals
  *
  * @Route("/deferral/graph", name="deferral_graph", options={"expose"=true})
  * @Template()
  */
 public function graphAction(Request $request)
 {
     if ($request->getMethod() == 'POST') {
         $principal = (int) $request->request->get('principal');
         $rate = (double) $request->request->get('rate');
         $recognitionRate = (double) $request->request->get('recognitionRate');
         $recognitionCap = (double) $request->request->get('recognitionCap');
         $periods = (int) $request->request->get('periods');
         $payments = $request->request->get('payments');
         $strategy = $request->request->get('strategy');
     } else {
         $principal = (int) $request->query->get('principal');
         $rate = (double) $request->query->get('rate');
         $recognitionRate = (double) $request->query->get('recognitionRate');
         $recognitionCap = (double) $request->query->get('recognitionCap');
         $periods = (int) $request->query->get('periods');
         $payments = $request->query->get('payments');
         $strategy = $request->query->get('strategy');
     }
     if (!$principal) {
         $principal = 1000;
     }
     if (!$rate) {
         $rate = 0.75;
     }
     if (!$recognitionRate) {
         $recognitionRate = 1 - $rate;
     }
     if (!$recognitionCap) {
         $recognitionCap = $principal;
     }
     if (!$periods) {
         $periods = 10;
     }
     if (!$payments) {
         $payments = array();
     }
     if (!$strategy) {
         $strategy = 'max';
     }
     $function = $strategy == 'even' ? 'distributePaymentEvenly' : 'distributePaymentMax';
     $d = new Deferral($principal, $rate, $periods);
     $schedule = $d->getSchedule();
     $runningTotal = 0;
     $totals = array();
     foreach ($schedule as $s) {
         $runningTotal += $s;
         $totals[] = $runningTotal;
     }
     $inits = array_fill(0, $periods, 0);
     $idx = 0;
     // Sort the $payments array by order key
     usort($payments, function ($a, $b) {
         return $a['period'] - $b['period'];
     });
     $paymentsTotal = 0;
     $paymentsTotal = array_reduce($payments, function ($result, $item) {
         $result += $item['amount'];
         return $result;
     });
     foreach ($payments as $payment) {
         $d = new Deferral($principal, $rate, $periods, $inits, null, $recognitionRate, $recognitionCap);
         $deferrals = $d->{$function}($payment['amount'], $periods - $payment['period']);
         $chartArrays[] = array('name' => "Payment {$idx} realized", 'type' => 'column', 'data' => $deferrals);
         $inits = $this->sumArraySlots($inits, $deferrals);
         $idx++;
     }
     // Chart
     $series = array(array("name" => "Monthly Payment Realized", "type" => 'column', "data" => $schedule), array("name" => "Deferral Schedule", "type" => 'spline', "data" => $totals));
     $runningPaymentTotal = 0;
     $paymentTotals = array_fill(0, $periods, 0);
     if (!empty($chartArrays)) {
         foreach ($chartArrays as $ca) {
             array_push($series, $ca);
             $paymentTotals = $this->sumArraySlots($paymentTotals, $ca['data']);
         }
         $tally = 0;
         foreach ($paymentTotals as $idx => $pt) {
             $tally += $pt;
             $myTotals[] = $tally;
         }
         // Push payment totals onto series
         array_push($series, array('name' => 'Cumulative Payment Realized', 'type' => 'spline', 'data' => $myTotals));
     }
     $ob = new Highchart();
     $ob->chart->renderTo('linechart');
     // The #id of the div where to render the chart
     $ob->title->text('Deferral Schedule');
     $ob->xAxis->title(array('text' => "Payment Periods (months)"));
     $ob->yAxis->title(array('text' => "Payment Realized (dollars)"));
     $ob->series($series);
     return $this->render('TSKPaymentBundle:Deferral:graph.html.twig', array('chart' => $ob, 'principal' => $principal, 'rate' => $rate, 'recognitionRate' => $recognitionRate, 'recognitionCap' => $recognitionCap, 'periods' => $periods, 'payments' => $payments, 'paymentsTotal' => $paymentsTotal, 'strategy' => $strategy, 'evenSelected' => $strategy == 'even' ? 'selected' : '', 'maxSelected' => $strategy == 'max' ? 'selected' : '', 'admin_pool' => $this->get('sonata.admin.pool')));
 }
 public function hobbiesChartAction()
 {
     $id = "hobbies_chart";
     $ob = new Highchart();
     $ob->chart->renderTo($id);
     $ob->chart->type('pie');
     $ob->title->text('Hobbies');
     $ob->plotOptions->series(array('dataLabels' => array('enabled' => true, 'format' => '{point.name}: {point.y:.1f}%')));
     $ob->tooltip->headerFormat('<span style="font-size:11px">{series.name}</span><br>');
     $ob->tooltip->pointFormat('<span style="color:{point.color}">{point.name}</span>: <b>{point.y:.2f}%</b> of total<br/>');
     $hobbies = $this->getDoctrine()->getManager()->getRepository('BuddySystemUserBundle:User')->getHobbies($this->container->get('section_manager')->getCurrentSection());
     $total = 0;
     foreach ($hobbies as $hobby) {
         if ($hobby['name'] != null && $hobby['nb'] > 0) {
             $total += intval($hobby['nb']);
         }
     }
     $data = array();
     foreach ($hobbies as $hobby) {
         if ($hobby['name'] != null && $hobby['nb'] > 0) {
             array_push($data, array($hobby['name'], round(intval($hobby['nb']) / $total * 100, 2)));
         }
     }
     $ob->series(array(array('name' => 'Hobbies', 'colorByPoint' => true, 'data' => $data)));
     return $this->render('BuddySystemMainBundle:HighCharts:chart.html.twig', array('id' => $id, 'chart' => $ob));
 }