/**
  * @return string
  */
 protected function renderChartContent()
 {
     $reportDataProviderToAmChartMakerAdapter = $this->dataProvider->makeReportDataProviderToAmChartMakerAdapter();
     Yii::import('ext.amcharts.AmChartMaker');
     $amChart = new AmChartMaker();
     $amChart->categoryField = ReportDataProviderToAmChartMakerAdapter::resolveFirstSeriesDisplayLabelName(1);
     $amChart->data = $reportDataProviderToAmChartMakerAdapter->getData();
     $amChart->id = $this->uniqueLayoutId;
     $amChart->type = $reportDataProviderToAmChartMakerAdapter->getType();
     $amChart->xAxisName = $this->dataProvider->resolveFirstSeriesLabel();
     $amChart->yAxisName = $this->dataProvider->resolveFirstRangeLabel();
     $amChart->yAxisUnitContent = $this->resolveYAxisUnitContent();
     if ($reportDataProviderToAmChartMakerAdapter->isStacked()) {
         for ($i = 1; $i < $reportDataProviderToAmChartMakerAdapter->getSecondSeriesValueCount() + 1; $i++) {
             $title = $reportDataProviderToAmChartMakerAdapter->getSecondSeriesDisplayLabelByKey($i);
             $balloonText = '"[[' . ReportDataProviderToAmChartMakerAdapter::resolveSecondSeriesDisplayLabelName($i) . ']] - [[' . ReportDataProviderToAmChartMakerAdapter::resolveFirstRangeDisplayLabelName($i) . ']] : [[' . ReportDataProviderToAmChartMakerAdapter::resolveFirstSeriesFormattedValueName($i) . ']] - [[' . ReportDataProviderToAmChartMakerAdapter::resolveSecondSeriesDisplayLabelName($i) . ']] : [[' . ReportDataProviderToAmChartMakerAdapter::resolveSecondSeriesFormattedValueName($i) . ']] "';
             $amChart->addSerialGraph(ReportDataProviderToAmChartMakerAdapter::resolveFirstSeriesValueName($i), 'column', array('title' => '"' . CJavaScript::quote($title) . '"', 'balloonText' => $balloonText));
         }
     } else {
         $amChart->addSerialGraph(ReportDataProviderToAmChartMakerAdapter::resolveFirstSeriesValueName(1), 'column');
     }
     $scriptContent = $amChart->javascriptChart();
     Yii::app()->getClientScript()->registerScript(__CLASS__ . '#' . $this->uniqueLayoutId, $scriptContent);
     $cClipWidget = new CClipWidget();
     $cClipWidget->beginClip("Chart" . $this->uniqueLayoutId);
     $cClipWidget->widget('application.core.widgets.AmChart', array('id' => $this->uniqueLayoutId));
     $cClipWidget->endClip();
     return $cClipWidget->getController()->clips['Chart' . $this->uniqueLayoutId];
 }
 /**
  * @return ReportDataProviderToAmChartMakerAdapter
  */
 protected function makeStackedReportDataProviderToAmChartMakerAdapter()
 {
     $resultsData = $this->fetchChartData();
     $firstRangeAttributeName = $this->resolveChartFirstRangeAttributeNameForReportResultsRowData();
     $secondRangeAttributeName = $this->resolveChartSecondRangeAttributeNameForReportResultsRowData();
     $chartData = array();
     $secondSeriesValueData = array();
     $secondSeriesDisplayLabels = array();
     $secondSeriesValueCount = 1;
     $firstSeriesDisplayAttributeKey = $this->getDisplayAttributeKeyByAttribute($this->report->getChart()->firstSeries);
     $secondSeriesDisplayAttributeKey = $this->getDisplayAttributeKeyByAttribute($this->report->getChart()->secondSeries);
     foreach ($resultsData as $data) {
         $firstSeriesDataValue = $data->resolveRawValueByDisplayAttributeKey($firstSeriesDisplayAttributeKey);
         $chartData[$firstSeriesDataValue] = array(ReportDataProviderToAmChartMakerAdapter::resolveFirstSeriesDisplayLabelName(1) => $this->getDisplayAttributeByAttribute($this->report->getChart()->firstSeries)->resolveValueAsLabelForHeaderCell($firstSeriesDataValue, true));
         $secondSeriesDataValue = $data->resolveRawValueByDisplayAttributeKey($secondSeriesDisplayAttributeKey);
         if (!isset($secondSeriesValueData[$secondSeriesDataValue])) {
             $secondSeriesValueData[$secondSeriesDataValue] = $secondSeriesValueCount;
             $secondSeriesDisplayLabels[$secondSeriesValueCount] = $this->getDisplayAttributeByAttribute($this->report->getChart()->secondSeries)->resolveValueAsLabelForHeaderCell($secondSeriesDataValue, true);
             $secondSeriesValueCount++;
         }
     }
     foreach ($resultsData as $data) {
         $firstSeriesDataValue = $data->resolveRawValueByDisplayAttributeKey($firstSeriesDisplayAttributeKey);
         $secondSeriesDataValue = $data->resolveRawValueByDisplayAttributeKey($secondSeriesDisplayAttributeKey);
         $secondSeriesKey = $secondSeriesValueData[$secondSeriesDataValue];
         if (!isset($chartData[$firstSeriesDataValue][ReportDataProviderToAmChartMakerAdapter::resolveFirstSeriesValueName($secondSeriesKey)])) {
             $chartData[$firstSeriesDataValue][ReportDataProviderToAmChartMakerAdapter::resolveFirstSeriesValueName($secondSeriesKey)] = 0;
         }
         $chartData[$firstSeriesDataValue][ReportDataProviderToAmChartMakerAdapter::resolveFirstSeriesValueName($secondSeriesKey)] += $data->{$firstRangeAttributeName};
         if (!isset($chartData[$firstSeriesDataValue][ReportDataProviderToAmChartMakerAdapter::resolveFirstRangeDisplayLabelName($secondSeriesKey)])) {
             $chartData[$firstSeriesDataValue][ReportDataProviderToAmChartMakerAdapter::resolveFirstRangeDisplayLabelName($secondSeriesKey)] = $this->getDisplayAttributeByAttribute($this->report->getChart()->firstRange)->label;
         }
         if (!isset($chartData[$firstSeriesDataValue][ReportDataProviderToAmChartMakerAdapter::resolveSecondSeriesValueName($secondSeriesKey)])) {
             $chartData[$firstSeriesDataValue][ReportDataProviderToAmChartMakerAdapter::resolveSecondSeriesValueName($secondSeriesKey)] = 0;
         }
         $chartData[$firstSeriesDataValue][ReportDataProviderToAmChartMakerAdapter::resolveSecondSeriesValueName($secondSeriesKey)] += $data->{$secondRangeAttributeName};
         if (!isset($chartData[$firstSeriesDataValue][ReportDataProviderToAmChartMakerAdapter::resolveSecondSeriesDisplayLabelName($secondSeriesKey)])) {
             $chartData[$firstSeriesDataValue][ReportDataProviderToAmChartMakerAdapter::resolveSecondSeriesDisplayLabelName($secondSeriesKey)] = $secondSeriesDisplayLabels[$secondSeriesKey];
         }
         if (!isset($chartData[$firstSeriesDataValue][ReportDataProviderToAmChartMakerAdapter::resolveSecondSeriesDisplayLabelName($secondSeriesKey)])) {
             $chartData[$firstSeriesDataValue][ReportDataProviderToAmChartMakerAdapter::resolveSecondSeriesDisplayLabelName($secondSeriesKey)] = $this->getDisplayAttributeByAttribute($this->report->getChart()->secondRange)->label;
         }
     }
     return new ReportDataProviderToAmChartMakerAdapter($this->report, array_values($chartData), $secondSeriesValueData, $secondSeriesDisplayLabels, $secondSeriesValueCount - 1);
 }
 public function testGetSecondSeriesDisplayLabelByKey()
 {
     $data = array();
     $secondSeriesValueData = array();
     $secondSeriesDisplayLabels = array('abc', 'def');
     $secondSeriesValueCount = 5;
     $chart = new ChartForReportForm();
     $chart->type = 'Bar2D';
     $chart->firstSeries = 'dropDown';
     $chart->firstRange = 'float__Summation';
     $chart->secondSeries = 'radioDropDown';
     $chart->secondRange = 'integer__Summation';
     $report = new Report();
     $report->setChart($chart);
     $adapter = new ReportDataProviderToAmChartMakerAdapter($report, $data, $secondSeriesValueData, $secondSeriesDisplayLabels, $secondSeriesValueCount);
     $this->assertEquals('def', $adapter->getSecondSeriesDisplayLabelByKey(1));
 }