/** * Method to get the options to populate list * * @return array The field option objects. * * @since 1.0 */ protected function getOptions() { $options = array_merge(parent::getOptions(), RHtmlRchart::getChartOptions()); return $options; }
<?php /** * @package Redcore * @subpackage Layouts * * @copyright Copyright (C) 2008 - 2015 redCOMPONENT.com. All rights reserved. * @license GNU General Public License version 2 or later, see LICENSE. */ defined('JPATH_REDCORE') or die; $data = $displayData; $chartOptions = $data['options']['chartOptions']; $chartType = $data['options']['chartType']; $chartData = $data['options']['chartData']; $chartId = $data['options']['chartId']; RHtmlRchart::addChart($chartType, '#' . $chartId, $chartData, $chartOptions); ?> <div class="container-fluid chart-container"> <div class="col-md-12 col-sm-12 chart-box"> <canvas id="<?php echo $chartId; ?> "></canvas> </div> <div id="<?php echo $chartId; ?> Legend" class="chart-legend-container col-md-12 col-sm-12"></div> </div>
?> <form action="<?php echo $action; ?> " name="adminForm" class="adminForm" id="adminForm" method="post"> <?php echo RLayoutHelper::render('searchtools.default', array('view' => $this, 'options' => array('filtersHidden' => false, 'searchField' => 'search_payment_dashboard', 'searchFieldSelector' => '#filter_search_payment_dashboard', 'limitFieldSelector' => '#list_payment_dashboard_limit', 'activeOrder' => $listOrder, 'activeDirection' => $listDirn))); ?> <div class="container-fluid"> <div class="col-lg-6 col-md-12"> <h2><?php echo JText::_('COM_REDCORE_PAYMENT_DASHBOARD_CHART'); ?> </h2> <?php echo RLayoutHelper::render('chart.chart', array('view' => $this, 'options' => array('chartOptions' => array('legendTemplate' => RHtmlRchart::getDefaultLegendHtml()), 'chartType' => $this->chartType, 'chartData' => $this->chartData, 'chartId' => 'mainPaymentChart'))); ?> </div> <div class="col-lg-6 col-md-12"> <h2><?php echo JText::_('COM_REDCORE_PAYMENT_DASHBOARD_STATISTICS'); ?> </h2> <table class="table table-condensed table-striped"> <tr> <th style="width: 40%;"> </th> <th> <?php echo JText::_('COM_REDCORE_PAYMENTS'); ?>
/** * Prepare Payment data for chart * * @param array $data Data used for chart definition * @param string $chartType Chart types: Line, Bar, Radar, PolarArea, Pie, Doughnut * * @return string * * @since 1.5 */ public static function prepareChartData($data, $chartType = 'Line') { $chartType = RHtmlRchart::getChartType($chartType); $chartData = array(); $amounts = $data['amounts']; $labels = $data['labels']; switch ($chartType) { case 'PolarArea': case 'Pie': case 'Doughnut': foreach ($amounts as $extensionName => $amount) { $dataValues = 0; $color = implode(',', RHtmlRchart::getColorFromHash($extensionName)); $strokeColor = implode(',', RHtmlRchart::getColorFromHash($extensionName, 'redcore')); foreach ($amount as $value) { $dataValues += $value['sum']; } $dataSet = new stdClass(); $dataSet->value = $dataValues; $dataSet->color = 'rgba(' . $color . ',0.5)'; $dataSet->highlight = 'rgba(' . $strokeColor . ',1)'; $dataSet->label = $extensionName; $chartData[] = $dataSet; } break; case 'Line': case 'Radar': case 'Bar': default: $chartData['labels'] = $labels; $chartData['datasets'] = array(); if (empty($amounts)) { // Needed for proper chart display $chartData['datasets'] = array(array()); } else { foreach ($amounts as $extensionName => $amount) { $dataValues = array(); $color = implode(',', RHtmlRchart::getColorFromHash($extensionName)); $strokeColor = implode(',', RHtmlRchart::getColorFromHash($extensionName, 'redcore')); foreach ($chartData['labels'] as $label) { $dataValues[] = !isset($amount[$label]) ? 0 : $amount[$label]; } $dataSet = array('label' => $extensionName, 'fillColor' => 'rgba(' . $color . ',0.2)', 'strokeColor' => 'rgba(' . $strokeColor . ',1)', 'data' => $dataValues); if ($chartType == 'Bar') { $dataSet['highlightFill'] = 'rgba(' . $color . ',0.75)'; $dataSet['highlightStroke'] = 'rgba(' . $color . ',1)'; } else { $dataSet['pointColor'] = 'rgba(' . $color . ',1)'; $dataSet['pointStrokeColor'] = '#fff'; $dataSet['pointHighlightFill'] = '#fff'; $dataSet['pointHighlightStroke'] = 'rgba(' . $color . ',1)'; } $chartData['datasets'][] = $dataSet; } } break; } return $chartData; }