public static function createFromResponse(\SimpleXMLElement $response)
 {
     $chart = new Chart();
     $chart->setFrom((int) $response->attributes()->from);
     $chart->setTo((int) $response->attributes()->to);
     return $chart;
 }
 /**
  * @return Chart
  */
 public static function getChart($cate)
 {
     /** @var Chart $chart */
     $chart = new Chart();
     $db = DB::getConn();
     $stm = $db->prepare('select uid, cate, ans from Answers where cate=:cate');
     $stm->bindParam(':cate', $cate);
     $stm->execute();
     $rs = $stm->fetchAll();
     $legends = [];
     foreach ($rs as $r) {
         $results = QuestionCtrl::getResByID($r['uid'], $r['cate']);
         $mark = 0;
         $total = 0;
         foreach ($results as $result) {
             $total += $result->getPoint();
             $mark += $result->getMark();
         }
         if ($total != 0) {
             $legends[] = number_format($mark * 100 / $total, 1, '.', ',');
         }
     }
     $chart->setLegends($legends);
     return $chart;
 }
 public function execute($type_report = '', $id_report = '')
 {
     $selected_id = ($type_report == "grafico" ? "chart_" : "report_") . $id_report;
     $this->showDashboard($selected_id);
     switch ($type_report) {
         case "relatorio":
             include "Report.php";
             $obj = new Report($id_report);
             break;
         case "grafico":
             include "Chart.php";
             $obj = new Chart($id_report);
             break;
     }
     $obj->execute();
 }
 public function init()
 {
     parent::init();
     $dataTable = $this->dataTable();
     $jOpts = self::encode($this->options);
     $id = $this->getId();
     $this->getView()->registerJs("var {$id}=new google.visualization.PieChart(document.getElementById('{$id}'));{$id}.draw({$dataTable},{$jOpts});");
 }
Example #5
0
 /**
  * 
  * get the JS library that we need to generate charts
  * @param  boolean $force forces the inclusion
  * @return string
  */
 public static function include_library($force = FALSE)
 {
     if (self::$included_lib == FALSE or $force == TRUE) {
         self::$included_lib = TRUE;
         return HTML::script((Core::is_HTTPS() ? 'https:' : 'http:') . '//www.google.com/jsapi') . PHP_EOL;
     }
     return FALSE;
 }
 /**
  * load jsapi
  */
 private function initChart()
 {
     self::$_first = false;
     $output = '';
     // start a code block
     $output .= '<script type="text/javascript" src="https://www.google.com/jsapi"></script>' . "\n";
     $output .= '<script type="text/javascript">google.load(\'visualization\', \'1.0\', {\'packages\':[\'corechart\']});</script>' . "\n";
     return $output;
 }
Example #7
0
 /**
  * @param string $title   The main title of the error. eg: "Unable to render the chart"
  * @param string $msg     The error message full of details
  * @param int    $aWidth  The width of the image (this forces the text to wrap) 
  *                        /!\ A too small width may lead to a jpgraph error
  * @param int    $aHeight The height of the image 
  *                        /!\ A too small width may lead to a jpgraph error
  */
 public function __construct($title, $msg, $aWidth = 600, $aHeight = 400)
 {
     parent::__construct($aWidth, $aHeight);
     $this->img_width = $aWidth;
     $this->jpgraph_instance->InitFrame();
     $padding = 10;
     $graph_title = $this->addTextToGraph($title, $padding, $padding, FS_BOLD, 12, $aWidth);
     $height = $graph_title->GetTextHeight($this->jpgraph_instance->img);
     $text = $this->addTextToGraph($msg, $padding, 2 * $padding + $height, FS_NORMAL, 8, $aWidth);
 }
Example #8
0
 protected function compute(array &$q)
 {
     if ($this->rotation) {
         $q['chp'] = $this->rotation;
     }
     parent::compute($q);
     // pie chart doesn't support data scaling.
     // however, i still want to compute a scale for encoding format
     unset($q['chds']);
 }
Example #9
0
 public function __construct($width, $height)
 {
     if ($width > self::MAX_WIDTH) {
         throw new InvalidArgumentException(sprintf('Max width for Map Chart is %d.', self::MAX_WIDTH));
     }
     if ($height > self::MAX_HEIGHT) {
         throw new InvalidArgumentException(sprintf('Max height for Map Chart is %d.', self::MAX_HEIGHT));
     }
     parent::__construct('t', $width, $height);
 }
Example #10
0
 public function actionIndex()
 {
     $active_user = User::require_active_user();
     $this->setLayoutVar('active_user', $active_user);
     $this->setVar('active_user', $active_user);
     $this->setLayoutVar('pageTitle', 'Charts');
     $this->setLayoutVar('pageHead', 'Charts');
     $most_snatched = Chart::most_snatched(array('limit' => 10));
     $top_uploaders = Chart::top_uploaders(array('limit' => 10, 'user' => $active_user));
     $this->setVar('most_snatched', $most_snatched);
     $this->setVar('top_uploaders', $top_uploaders);
 }
Example #11
0
 /**
  * Helper method which returns the smallest value from all series
  *
  * @return  float
  */
 public function min()
 {
     if ($this->getAccumulated()) {
         return parent::min();
     }
     $min = [];
     for ($i = 0, $s = sizeof($this->series); $i < $s; $i++) {
         for ($j = 0, $c = sizeof($this->series[$i]->values); $j < $c; $j++) {
             @($min[$j] += $this->series[$i]->values[$j]);
         }
     }
     return min($min) < 0 ? min($min) : 0;
 }
 public function showPage($selected = '')
 {
     if (!FUTURI_Session::isUserAdmin()) {
         $this->load->view("nopermission_admin");
     }
     $this->load->view("admin_header", array('selected' => $selected));
     switch ($selected) {
         case "usuarios":
             include "application/controllers/User.php";
             define_constants();
             $userController = new User();
             $userController->showListPage('', 10, false);
             break;
         case "estatisticas":
             break;
         case "backups":
             include "application/controllers/Backup.php";
             define_constants();
             $backupController = new Backup();
             $backupController->showListPage('', 10, false);
             break;
         case "configs":
             $this->load->view("admin_configs", array("object_handler" => $this));
             break;
         case "relatorios":
             include "application/controllers/Report.php";
             define_constants();
             $reportController = new Report();
             $reportController->showListPage('', 10, false);
             break;
         case "graficos":
             include "application/controllers/Chart.php";
             define_constants();
             $chartController = new Chart();
             $chartController->showListPage('', 10, false);
             break;
     }
 }
Example #13
0
 function __set($key, $value)
 {
     switch ($key) {
         case 'width':
             $this->width = $value;
             break;
         case 'height':
             $this->height = $value;
             break;
         default:
             parent::__set($key, $value);
             break;
     }
 }
Example #14
0
 /**
  * Resets all references to other model objects or collections of model objects.
  *
  * This method is a user-space workaround for PHP's inability to garbage collect
  * objects with circular references (even in PHP 5.3). This is currently necessary
  * when using Propel in certain daemon or large-volumne/high-memory operations.
  *
  * @param boolean $deep Whether to also clear the references on all referrer objects.
  */
 public function clearAllReferences($deep = false)
 {
     if ($deep && !$this->alreadyInClearAllReferencesDeep) {
         $this->alreadyInClearAllReferencesDeep = true;
         if ($this->aUser instanceof Persistent) {
             $this->aUser->clearAllReferences($deep);
         }
         if ($this->aChart instanceof Persistent) {
             $this->aChart->clearAllReferences($deep);
         }
         $this->alreadyInClearAllReferencesDeep = false;
     }
     // if ($deep)
     $this->aUser = null;
     $this->aChart = null;
 }
Example #15
0
 /**
  * Create the image.
  */
 protected function createImage()
 {
     parent::createImage();
     // Get graphical obects
     $img = $this->plot->getImg();
     $palette = $this->plot->getPalette();
     $text = $this->plot->getText();
     $primitive = $this->plot->getPrimitive();
     // Get the graph area
     $graphArea = $this->plot->getGraphArea();
     // Aqua-like background
     for ($i = $graphArea->y1; $i < $graphArea->y2; $i++) {
         $color = $palette->backgroundColor[($i + 3) % 4];
         $primitive->line($graphArea->x1, $i, $graphArea->x2, $i, $color);
     }
 }
 public function init()
 {
     parent::init();
     $dataTable = $this->dataTable();
     $jOpts = self::encode($this->options);
     $id = $this->getId();
     if ($this->mode == 'classic') {
         $package = 'corechart';
         $call = "var {$id}=new google.visualization.ColumnChart(document.getElementById('{$id}'));{$id}.draw({$dataTable},{$jOpts});";
     } else {
         $package = 'bar';
         if ($this->mode == 'transition') {
             $jOpts = "google.charts.Bar.convertOptions({$jOpts})";
         }
         $call = "var {$id}=new google.charts.Bar(document.getElementById('{$id}'));{$id}.draw({$dataTable},{$jOpts});";
     }
     $this->packages = [$package];
     $this->getView()->registerJs($call);
 }
Example #17
0
 /**
  * Constructor
  * 
  * @param int    $aWidth      Default is 0
  * @param int    $aHeight     Default is 0
  * @param string $aCachedName Default is ""
  * @param int    $aTimeOut    Default is 0
  * @param bool   $aInline     Default is true
  * 
  * @return void
  */
 public function __construct($aWidth = 0, $aHeight = 0, $aCachedName = "", $aTimeOut = 0, $aInline = true)
 {
     parent::__construct($aWidth, $aHeight, $aCachedName, $aTimeOut, $aInline);
     $header_color = $GLOBALS['HTML']->getGanttHeaderColor();
     $this->scale->year->grid->SetColor($this->getMainColor());
     $this->scale->year->grid->Show(true);
     $this->scale->year->SetBackgroundColor($header_color);
     $this->scale->year->SetFont($this->getFont(), FS_NORMAL, 8);
     $this->scale->month->grid->SetColor($this->getMainColor());
     $this->scale->month->grid->Show(true);
     $this->scale->month->SetBackgroundColor($header_color);
     $this->scale->month->SetFont($this->getFont(), FS_NORMAL, 8);
     $this->scale->week->grid->SetColor($this->getMainColor());
     $this->scale->week->SetFont($this->getFont(), FS_NORMAL, 8);
     $this->scale->day->grid->SetColor($this->getMainColor());
     $this->scale->day->SetFont($this->getFont(), FS_NORMAL, 6);
     $this->scale->actinfo->SetBackgroundColor($header_color);
     $this->scale->actinfo->SetFont($this->getFont(), FS_NORMAL, 8);
     $this->scale->actinfo->vgrid->SetColor($header_color);
 }
Example #18
0
 public function report()
 {
     // // Group IQs by gender
     // $genderIQs = array();
     // foreach ($this->_humans as $human) {
     //     if ($human instanceof Human) {
     //         $genderIQs[$human->getGender()][] = $human->getIQ();
     //     }
     // }
     // // Output gender IQ distribution
     // foreach ($genderIQs as $gender => $iQs) {
     //     echo $gender . ': ' . count($iQs) . "\n";
     //     echo Chart::output(self::IQ_INIT_BASE - self::IQ_INIT_VAR, self::IQ_INIT_BASE + self::IQ_INIT_VAR, 5, $iQs);
     // }
     $iQs = array();
     foreach ($this->_humans as $human) {
         $iQs[] = $human->getIQ();
     }
     echo 'Count: ' . count($iQs) . "\n";
     echo Chart::output(self::IQ_INIT_BASE - self::IQ_INIT_VAR, self::IQ_INIT_BASE + self::IQ_INIT_VAR, 5, $iQs);
 }
Example #19
0
 /**
  * @return Chart
  */
 public function buildGraph()
 {
     $graph = new Chart($this->width, $this->height);
     $graph->SetScale("datlin");
     $graph->title->Set($this->title);
     $graph->subtitle->Set($this->description);
     $colors = $graph->getThemedColors();
     $graph->xaxis->SetTickLabels($this->burndown_data->getHumanReadableDates());
     $remaining_effort = new LinePlot($this->burndown_data->getRemainingEffort());
     $remaining_effort->SetColor($colors[1] . ':0.7');
     $remaining_effort->SetWeight(2);
     $remaining_effort->SetLegend('Remaining effort');
     $remaining_effort->mark->SetType(MARK_FILLEDCIRCLE);
     $remaining_effort->mark->SetColor($colors[1] . ':0.7');
     $remaining_effort->mark->SetFillColor($colors[1]);
     $remaining_effort->mark->SetSize(3);
     $graph->Add($remaining_effort);
     $ideal_burndown = new LinePlot($this->burndown_data->getIdealEffort());
     $ideal_burndown->SetColor($colors[0] . ':1.25');
     $ideal_burndown->SetLegend('Ideal Burndown');
     $graph->Add($ideal_burndown);
     return $graph;
 }
Example #20
0
<?php

require '../lib/Chart.php';
$chart = new Chart('lc', 500, 200);
$chart->setScale(0, 100);
$line = new ChartData(array(10, 12, 15, 20, 22, 50, 60, 63, 58, 75, 67, 80));
$chart->addData($line);
$y_axis = new ChartAxis('y');
$chart->addAxis($y_axis);
$x_axis = new ChartAxis('x');
$chart->addAxis($x_axis);
if (isset($_GET['debug'])) {
    var_dump($chart->getQuery());
    echo $chart->validate();
    echo $chart->toHtml();
} else {
    header('Content-Type: image/png');
    echo $chart;
}
 /**
  * Create a JpGraph accumulated barPlot chart 
  *
  * @param Array $bplot Array of JpGraph barPlot objects
  * @param Chart $graph The output graph that will contains accumulated barPlots
  *
  * @return Void
  */
 private function displayAccumulatedGraph($bplot, $graph)
 {
     $abplot = new AccBarPlot($bplot);
     $abplot->SetAbsWidth(10);
     $graph->Add($abplot);
     $graph->Stroke();
 }
Example #22
0
 /**
  * Creates the pie chart image
  *
  * @access	private
  */
 function createImage()
 {
     parent::createImage();
     $pieColors = array(array(2, 78, 0), array(148, 170, 36), array(233, 191, 49), array(240, 127, 41), array(243, 63, 34), array(190, 71, 47), array(135, 81, 60), array(128, 78, 162), array(121, 75, 255), array(142, 165, 250), array(162, 254, 239), array(137, 240, 166), array(104, 221, 71), array(98, 174, 35), array(93, 129, 1));
     $this->pieColor = array();
     $this->pieShadowColor = array();
     $shadowFactor = 0.5;
     foreach ($pieColors as $colorRGB) {
         list($red, $green, $blue) = $colorRGB;
         $color = new Color($red, $green, $blue);
         $shadowColor = new Color($red * $shadowFactor, $green * $shadowFactor, $blue * $shadowFactor);
         array_push($this->pieColor, $color);
         array_push($this->pieShadowColor, $shadowColor);
     }
     $this->axisColor1 = new Color(201, 201, 201);
     $this->axisColor2 = new Color(158, 158, 158);
     $this->aquaColor1 = new Color(242, 242, 242);
     $this->aquaColor2 = new Color(231, 231, 231);
     $this->aquaColor3 = new Color(239, 239, 239);
     $this->aquaColor4 = new Color(253, 253, 253);
     // Legend box
     $this->outlinedBox($this->pieTLX, $this->pieTLY, $this->pieBRX, $this->pieBRY);
     // Aqua-like background
     $aquaColor = array($this->aquaColor1, $this->aquaColor2, $this->aquaColor3, $this->aquaColor4);
     for ($i = $this->pieTLY + 2; $i < $this->pieBRY - 1; $i++) {
         $color = $aquaColor[($i + 3) % 4];
         $this->primitive->line($this->pieTLX + 2, $i, $this->pieBRX - 2, $i, $color);
     }
 }
Example #23
0
" data-date="<?php 
echo $to_date;
?>
" data-date-format="yyyy-mm-dd">
                            <span class="input-group-addon">
                                <span class="glyphicon glyphicon-calendar"></span>
                            </span>
                        </div>
                    </div>
                    <button type="submit" class="btn btn-primary"><?php 
echo __('Filter');
?>
</button>
                </form>

                <br>
                
                <?php 
echo Chart::column($stats_daily, array('title' => __('Views and Ads statistics'), 'height' => 400, 'width' => 800, 'series' => '{0:{targetAxisIndex:1, visibleInLegend: true}}'));
?>
          
                
                
                <?php 
echo Chart::column($stats_orders, array('title' => __('Sales statistics'), 'height' => 400, 'width' => 800, 'series' => '{0:{targetAxisIndex:1, visibleInLegend: true}}'));
?>
                                                              
            </div>
        </div>
    </div> <!-- /.col-md-9 -->
</div> <!-- /.row -->
 /**
  * Renders a chart
  *
  * @param   img.chart.Chart chart
  * @return  img.Image
  * @throws  lang.IllegalArgumentException if chart is not renderable
  */
 public function render(Chart $chart)
 {
     // Method overloading by delegation
     $method = 'render' . $chart->getSimpleName();
     if (!method_exists($this, $method)) {
         throw new IllegalArgumentException('Cannot render ' . xp::typeOf($chart) . 's');
     }
     return call_user_func_array(array($this, $method), array($chart));
 }
Example #25
0
<?php

require '../lib/Chart.php';
require '../lib/markers/ChartTextMarker.php';
$values = array();
for ($i = 0; $i <= 10; $i += 1) {
    $values[] = rand(20, 80);
}
$chart = new Chart('bvs', 500, 200);
$chart->setScale(0, 100);
$data = new ChartData($values);
$chart->addData($data);
$marker = new ChartTextMarker();
$marker->setData($data);
$chart->addMarker($marker);
header('Content-Type: image/png');
echo $chart;
Example #26
0
    ?>
                    <?php 
} else {
    ?>
                         --
                    <?php 
}
?>
                </h2>
                <hr class="statcard-hr">
            </div>
            <?php 
$chart_colors = array(array('fill' => 'rgba(33,150,243,.1)', 'stroke' => 'rgba(33,150,243,.8)', 'point' => 'rgba(33,150,243,.8)', 'pointStroke' => 'rgba(33,150,243,.8)'));
?>
            <?php 
echo Chart::line($current_by_date, array('height' => 94, 'width' => 378, 'options' => array('animation' => false, 'responsive' => true, 'bezierCurve' => true, 'bezierCurveTension' => '.25', 'showScale' => true, 'pointDotRadius' => 0, 'pointDotStrokeWidth' => 0, 'pointDot' => false, 'maintainAspectRatio' => true, 'scaleShowVerticalLines' => false, 'tooltipTemplate' => '<%= datasetLabel %><%= value %>', 'multiTooltipTemplate' => '<%= datasetLabel %><%= value %>', 'showTooltips' => true)), $chart_colors);
?>
        </div>
    </div>
    <div class="col-md-12">
        <div class="statcard statcard-success">
            <ul class="nav nav-pills nav-justified text-center">
                <li role="presentation">
                    <div class="p-a">
                        <span class="statcard-desc"><?php 
echo __('Current');
?>
</span>
                        <h2 class="statcard-number">
                            <?php 
if ($current_total !== NULL) {
Example #27
0
 /**
  * Create the image
  *
  * @access	protected
  */
 function createImage()
 {
     parent::createImage();
     $this->axisColor1 = new Color(201, 201, 201);
     $this->axisColor2 = new Color(158, 158, 158);
     $this->aquaColor1 = new Color(242, 242, 242);
     $this->aquaColor2 = new Color(231, 231, 231);
     $this->aquaColor3 = new Color(239, 239, 239);
     $this->aquaColor4 = new Color(253, 253, 253);
     $this->barColor1 = new Color(42, 71, 181);
     $this->barColor2 = new Color(33, 56, 143);
     $this->barColor3 = new Color(172, 172, 210);
     $this->barColor4 = new Color(117, 117, 143);
     // Aqua-like background
     $aquaColor = array($this->aquaColor1, $this->aquaColor2, $this->aquaColor3, $this->aquaColor4);
     for ($i = $this->graphTLY; $i < $this->graphBRY; $i++) {
         $color = $aquaColor[($i + 3) % 4];
         $this->primitive->line($this->graphTLX, $i, $this->graphBRX, $i, $color);
     }
     // Axis
     imagerectangle($this->img, $this->graphTLX - 1, $this->graphTLY, $this->graphTLX, $this->graphBRY, $this->axisColor1->getColor($this->img));
     imagerectangle($this->img, $this->graphTLX - 1, $this->graphBRY, $this->graphBRX, $this->graphBRY + 1, $this->axisColor1->getColor($this->img));
 }
Example #28
0
        ?>
                            --
                        <?php 
    }
    ?>
                    </h2>
                <?php 
}
?>
                <hr class="statcard-hr">
            </div>
            <?php 
$chart_colors = array(array('fill' => 'rgba(33,150,243,.1)', 'stroke' => 'rgba(33,150,243,.8)', 'point' => 'rgba(33,150,243,.8)', 'pointStroke' => 'rgba(33,150,243,.8)'));
?>
            <?php 
echo Chart::line($current_by_date, array('height' => 94, 'width' => 378, 'options' => array('responsive' => true, 'maintainAspectRatio' => true, 'scaleShowVerticalLines' => false, 'scales' => array('xAxes' => array(array('gridLines' => array('display' => false))), 'yAxes' => array(array('ticks' => array('min' => 0)))), 'legend' => array('display' => false), 'tooltipTemplate' => '<%= datasetLabel %><%= value %>', 'multiTooltipTemplate' => '<%= datasetLabel %><%= value %>')), $chart_colors);
?>
        </div>
    </div>
    <div class="col-md-12">
        <div class="statcard statcard-success">
            <ul class="nav nav-pills nav-justified text-center">
                <li role="presentation">
                    <div class="p-a">
                        <span class="statcard-desc"><?php 
echo __('Current');
?>
</span>
                        <h2 class="statcard-number">
                            <?php 
if ($current_total !== NULL) {
Example #29
0
 /**
  * Resets all references to other model objects or collections of model objects.
  *
  * This method is a user-space workaround for PHP's inability to garbage collect
  * objects with circular references (even in PHP 5.3). This is currently necessary
  * when using Propel in certain daemon or large-volumne/high-memory operations.
  *
  * @param boolean $deep Whether to also clear the references on all referrer objects.
  */
 public function clearAllReferences($deep = false)
 {
     if ($deep && !$this->alreadyInClearAllReferencesDeep) {
         $this->alreadyInClearAllReferencesDeep = true;
         if ($this->collChartsRelatedById) {
             foreach ($this->collChartsRelatedById as $o) {
                 $o->clearAllReferences($deep);
             }
         }
         if ($this->collJobs) {
             foreach ($this->collJobs as $o) {
                 $o->clearAllReferences($deep);
             }
         }
         if ($this->aUser instanceof Persistent) {
             $this->aUser->clearAllReferences($deep);
         }
         if ($this->aOrganization instanceof Persistent) {
             $this->aOrganization->clearAllReferences($deep);
         }
         if ($this->aChartRelatedByForkedFrom instanceof Persistent) {
             $this->aChartRelatedByForkedFrom->clearAllReferences($deep);
         }
         $this->alreadyInClearAllReferencesDeep = false;
     }
     // if ($deep)
     if ($this->collChartsRelatedById instanceof PropelCollection) {
         $this->collChartsRelatedById->clearIterator();
     }
     $this->collChartsRelatedById = null;
     if ($this->collJobs instanceof PropelCollection) {
         $this->collJobs->clearIterator();
     }
     $this->collJobs = null;
     $this->aUser = null;
     $this->aOrganization = null;
     $this->aChartRelatedByForkedFrom = null;
 }
Example #30
0
 /**
  * Declares an association between this object and a Chart object.
  *
  * @param      Chart $v
  * @return     Job The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setChart(Chart $v = null)
 {
     if ($v === null) {
         $this->setChartId(NULL);
     } else {
         $this->setChartId($v->getId());
     }
     $this->aChart = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Chart object, it will not be re-added.
     if ($v !== null) {
         $v->addJob($this);
     }
     return $this;
 }