45 protected $controllerId;
55 protected $dataProvider;
60 protected $uniqueLayoutId;
65 protected static $maximumGroupsPerChart = 100;
72 assert(
'is_int($value)');
73 self::$maximumGroupsPerChart = $value;
84 assert(
'is_string($controllerId)');
85 assert(
'is_string($moduleId)');
86 assert(
'is_string($uniqueLayoutId)');
87 $this->controllerId = $controllerId;
88 $this->moduleId = $moduleId;
89 $this->dataProvider = $dataProvider;
90 $this->uniqueLayoutId = $uniqueLayoutId;
98 if ($this->dataProvider->calculateTotalItemCount() > self::$maximumGroupsPerChart)
110 $reportDataProviderToAmChartMakerAdapter = $this->dataProvider->makeReportDataProviderToAmChartMakerAdapter();
111 Yii::import(
'ext.amcharts.AmChartMaker');
112 $amChart =
new AmChartMaker();
114 $amChart->data = $reportDataProviderToAmChartMakerAdapter->getData();
115 $amChart->id = $this->uniqueLayoutId;
116 $amChart->type = $reportDataProviderToAmChartMakerAdapter->getType();
117 $amChart->xAxisName = $this->dataProvider->resolveFirstSeriesLabel();
118 $amChart->yAxisName = $this->dataProvider->resolveFirstRangeLabel();
120 if ($reportDataProviderToAmChartMakerAdapter->isStacked())
122 for ($i = 1; $i < ($reportDataProviderToAmChartMakerAdapter->getSecondSeriesValueCount() + 1); $i++)
124 $title = $reportDataProviderToAmChartMakerAdapter->getSecondSeriesDisplayLabelByKey($i);
132 array(
'title' =>
'"' . CJavaScript::quote($title) .
'"',
'balloonText' => $balloonText));
139 $scriptContent = $amChart->javascriptChart();
140 Yii::app()->getClientScript()->registerScript(__CLASS__ .
'#' . $this->uniqueLayoutId, $scriptContent);
141 $cClipWidget =
new CClipWidget();
142 $cClipWidget->beginClip(
"Chart" . $this->uniqueLayoutId);
143 $cClipWidget->widget(
'application.core.widgets.AmChart', array(
'id' => $this->uniqueLayoutId));
144 $cClipWidget->endClip();
145 return $cClipWidget->getController()->clips[
'Chart' . $this->uniqueLayoutId];
153 $content =
'<div class="general-issue-notice"><span class="icon-notice"></span><p>';
154 $content .= Zurmo::t(
'ReportsModule',
'Your report has too many groups to plot. ' .
155 'Please adjust the filters to reduce the number below {maximum}.',
156 array(
'{maximum}' => self::$maximumGroupsPerChart));
157 $content .=
'</p></div>';
167 if ($this->dataProvider->getReport()->getCurrencyConversionType() ==
172 elseif ($this->dataProvider->getReport()->getCurrencyConversionType() ==
175 if ($this->dataProvider->resolveIsFirstRangeAttributeATypeOfCurrencyValue())
178 return Yii::app()->locale->getCurrencySymbol(Yii::app()->currencyHelper->getBaseCode());
185 elseif ($this->dataProvider->getReport()->getCurrencyConversionType() ==
188 if ($this->dataProvider->resolveIsFirstRangeAttributeATypeOfCurrencyValue())
191 return Yii::app()->locale->getCurrencySymbol(
192 $this->dataProvider->getReport()->getSpotConversionCurrencyCode());
const CURRENCY_CONVERSION_TYPE_SPOT
const CURRENCY_CONVERSION_TYPE_BASE
static resolveSecondSeriesFormattedValueName($key)
static resolveFirstSeriesValueName($key)
static resolveFirstRangeDisplayLabelName($key)
resolveYAxisUnitContent()
const CURRENCY_CONVERSION_TYPE_ACTUAL
static setMaximumGroupsPerChart($value)
__construct($controllerId, $moduleId, SummationReportDataProvider $dataProvider, $uniqueLayoutId)
static resolveFirstSeriesDisplayLabelName($key)
static resolveFirstSeriesFormattedValueName($key)
renderMaximumGroupsContent()
static resolveSecondSeriesDisplayLabelName($key)