public function renderContent()
 {
     $accessContent = $this->resolveContentIfCurrentUserCanAccessChartByModule('OpportunitiesModule', 'OpportunitiesModulePluralLabel');
     if ($accessContent != null) {
         return $accessContent;
     }
     $chartDataProviderType = $this->getChartDataProviderType();
     $chartDataProvider = ChartDataProviderFactory::createByType($chartDataProviderType);
     ControllerSecurityUtil::resolveCanCurrentUserAccessModule($chartDataProvider->getModel()->getModuleClassName(), true);
     $chartData = $chartDataProvider->getChartData();
     Yii::import('ext.amcharts.AmChartMaker');
     $amChart = new AmChartMaker();
     $amChart->data = $chartData;
     $amChart->id = $this->uniqueLayoutId;
     $amChart->type = $this->resolveViewAndMetadataValueByName('type');
     $amChart->addSerialGraph('value', 'column');
     $amChart->xAxisName = $chartDataProvider->getXAxisName();
     $amChart->yAxisName = $chartDataProvider->getYAxisName();
     $amChart->yAxisUnitContent = Yii::app()->locale->getCurrencySymbol(Yii::app()->currencyHelper->getCodeForCurrentUserForDisplay());
     $javascript = $amChart->javascriptChart();
     Yii::app()->getClientScript()->registerScript(__CLASS__ . '#' . $this->uniqueLayoutId, $javascript);
     $cClipWidget = new CClipWidget();
     $cClipWidget->beginClip("Chart");
     $cClipWidget->widget('application.core.widgets.AmChart', array('id' => $this->uniqueLayoutId));
     $cClipWidget->endClip();
     return $cClipWidget->getController()->clips['Chart'];
 }
 /**
  * @depends testGetChartDataUsingReadOptimization
  */
 public function testGetChartDataConvertedToNewCurrency()
 {
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $this->assertNull($super->currency->code);
     //Make a new currency and assign to the current user.
     $currency = new Currency();
     $currency->code = 'EUR';
     $currency->rateToBase = 0.5;
     //I wish...
     $this->assertTrue($currency->save());
     $super->currency = $currency;
     $this->assertTrue($super->save());
     $chartDataProvider = ChartDataProviderFactory::createByType('ContractsByStage');
     $chartData = $chartDataProvider->getChartData();
     $compareData = array(array('value' => 1100, 'displayLabel' => 'Negotiating'), array('value' => 200, 'displayLabel' => 'Verbal'));
     $this->assertEquals($compareData, $chartData);
     $chartDataProvider = ChartDataProviderFactory::createByType('ContractsBySource');
     $chartData = $chartDataProvider->getChartData();
     $compareData = array(array('value' => 400, 'displayLabel' => 'Outbound'), array('value' => 900, 'displayLabel' => 'Trade Show'));
     $this->assertEquals($compareData, $chartData);
 }
Ejemplo n.º 3
0
 /**
  * @param $type
  * @return ChartDataProvider
  */
 protected function resolveChartDataProvider($type)
 {
     assert('is_string($type)');
     $chartDataProvider = ChartDataProviderFactory::createByType($type);
     $chartDataProvider->setBeginDate($this->resolveForm()->beginDate);
     $chartDataProvider->setEndDate($this->resolveForm()->endDate);
     $chartDataProvider->setGroupBy($this->resolveForm()->groupBy);
     return $chartDataProvider;
 }
 protected function resolveChartDataProvider($type)
 {
     assert('is_string($type)');
     $chartDataProvider = ChartDataProviderFactory::createByType($type);
     return $chartDataProvider;
 }