你好,我正在使用highcharts plugin cakephp为我的系统做一个grafic现在的问题是我试图在3d中做这个grafic,highchart有这个选项但在我的系统中找不到,这是我的代码:
控制器一切正常但不在3d
public function columnacompra($id = null)
{
$this->loadModel('Soya');
$this->loadModel("SoyaProductorCompra");
$years = $this->SoyaProductorCompra->getYears();
$distinct_years = array();
foreach($years as $year) {
$distinct_years[] = $year[0]['distinct_year'];
}
$this->set(compact('distinct_years'));
if (!$id) {
$this->Session->setFlash('Porfavor provea un id de usuario');
$this->redirect(array('action'=>'index'));
}
$user = $this->Soya->findById($id);
if (!$user) {
$this->Session->setFlash('El id proporcionado no es valido');
$this->redirect(array('action'=>'index'));
}
if (!$this->request->data) {
$this->request->data = $user;
}
$SoyaMensual = array(120, 265, 245, 120, 265, 245,120, 265, 245,120, 265, 245);
$SoyaDiario = array(120, 265, 245, 120, 265, 245,120, 265, 245,120, 265, 245);
$chartName = 'Stacked Grouped Column Chart';
$mychart = $this->HighCharts->create( $chartName, 'column' );
$this->HighCharts->setChartParams(
$chartName,
array(
'renderTo' => 'columnwrapper', // div to display chart inside
'options3dEnabled' => true, //not found
'chartWidth' => 1000,
'chartHeight' => 750,
'chartBackgroundColorLinearGradient' => array(0,0,0,300),
'chartBackgroundColorStops' => array(array(0,'rgb(217, 217, 217)'),array(1,'rgb(255, 255, 255)')),
'title' => 'Tabla Comparativa',
'subtitle' => 'Soya Compras',
'xAxisLabelsEnabled' => TRUE,
'xAxisCategories' => array( 'Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'),
'yAxisTitleText' => 'Cantidad en (TM)',
'enableAutoStep' => FALSE,
'creditsEnabled' => FALSE,
'plotOptionsSeriesStacking' => 'normal'
)
);
$johnSeries = $this->HighCharts->addChartSeries();
$janeSeries = $this->HighCharts->addChartSeries();
$johnSeries->addName('Mensual')
->addData($SoyaMensual)
->stack = 'compra';
$janeSeries->addName('Diario')
->addData($SoyaDiario)
->stack = 'compra';
$mychart->addSeries($johnSeries);
$mychart->addSeries($janeSeries);
}
视图在这里
<div class="actions">
<h3>Acciones</h3>
<ul>
<li><?php echo $this->Html->link( "Volver Atras", array('action'=>'graficas', $this->data['Soya']['id'])); ?></li>
</ul>
</div>
<div class="chart">
<h2>Tabla Comparativa de la cantidad de compras</h2>
<?php echo $this->Html->script('modules/exporting');?>
<?php echo $this->Html->script('highcharts-3d');?>
<div id="columnwrapper" style="display: block; float: left; width:90%; margin-bottom: 20px;"></div>
<div class="clear"></div>
<?php echo $this->HighCharts->render('Stacked Grouped Column Chart'); ?>
</div>
答案 0 :(得分:1)
截至日前,CakePHP Highcharts plugin已更新为支持3D排行榜。您可以在Github上提供的插件演示代码中找到有关如何实现它的代码示例。
以下是如何为3D柱形图设置控制器操作:
public function column3d() {
$chartData = array(
29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4
);
$chartName = 'Column 3D Chart';
$mychart = $this->Highcharts->create($chartName, 'column');
$this->Highcharts->setChartParams($chartName, array(
'renderTo' => 'column3dwrapper', // div to display chart inside
'chartWidth' => 1000,
'chartHeight' => 750,
'title' => '3D Column Chart Demo',
'subtitle' => 'Source: World Bank',
'options3d' => array(
'enabled' => true,
'alpha' => 15,
'beta' => 15,
'depth' => 50,
'viewDistance' => 25
),
'xAxisLabelsEnabled' => true,
'yAxisTitleText' => 'Units',
'enableAutoStep' => false,
'creditsEnabled' => false,
)
);
$series = $this->Highcharts->addChartSeries();
$series->addName('3D Series')
->addData($chartData);
$mychart->addSeries($series);
$this->set(compact('chartName'));
}
在column3d.ctp视图文件中,您将获得以下内容:
<div class="chart">
<h4>Column 3D Chart</h4>
<div id="column3dwrapper" style="display: block; float: left; width:90%; margin-bottom: 20px;"></div>
<div class="clear"></div>
<?php echo $this->Highcharts->render($chartName); ?>
答案 1 :(得分:0)
根据他们的代码,CakePHP使用的是3.x版本,而3D图表是在4.x版本中引入的。我猜那时它不受支持。