Skip to content

Commit

Permalink
Added chart type column range to plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Boes committed Jun 2, 2015
1 parent ee2f3b0 commit eab57d0
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Controller/Component/HighchartsComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ public function create($name, $type) {
$this->charts[$name] = & $this->$name;
$chart = $this->$name;
break;
case 'columnrange':
App::import('Vendor', 'Highcharts.HighRollerColumnrangeChart', true, array(), 'HighRollerColumnrangeChart.php');
$this->$name = new HighRollerColumnrangeChart();
$this->charts[$name] = & $this->$name;
$chart = $this->$name;
break;
default:
App::import('Vendor', 'Highcharts.HighRollerColumnChart', true, array(), 'HighRollerColumnChart.php');
$this->$name = new HighRollerColumnChart();
Expand Down Expand Up @@ -251,6 +257,9 @@ public function setChartParams($name, $params = array()) {
if (isset($params['renderTo'])) {
$this->charts[$name]->chart->renderTo = $params['renderTo'];
}
if (isset($params['inverted'])) {
$this->charts[$name]->chart->inverted = $params['inverted'];
}
if (isset($params['reflow'])) {
$this->charts[$name]->chart->reflow = $params['reflow'];
}
Expand Down
99 changes: 99 additions & 0 deletions Controller/SingleSeriesDemoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,23 @@ class SingleSeriesDemoController extends HighchartsAppController {
public $helpers = array('Html');
public $uses = array();
public $layout = 'Highcharts.chart.demo';

public $chartData = array(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6);
public $columnrangechartData = array(
array(-9.7, 9.4),
array(-8.7, 6.5),
array(-3.5, 9.4),
array(-1.4, 19.9),
array(0.0, 22.6),
array(2.9, 29.5),
array(9.2, 30.7),
array(7.3, 26.5),
array(4.4, 18.0),
array(-3.1, 11.4),
array(-5.2, 10.4),
array(-13.5, 9.8)
);

public $Highcharts = null;

public function area() {
Expand Down Expand Up @@ -363,6 +379,89 @@ public function column() {
$this->set(compact('chartName'));
}

public function columnrange() {

$chartName = 'Columnrange Chart';

$mychart = $this->Highcharts->create($chartName, 'columnrange');

$this->Highcharts->setChartParams($chartName, array(
'renderTo' => 'columnrangewrapper', // div to display chart inside
'inverted' => TRUE,
'chartWidth' => 800,
'chartHeight' => 600,
'chartMarginTop' => 60,
'chartMarginLeft' => 90,
'chartMarginRight' => 30,
'chartMarginBottom' => 110,
'chartSpacingRight' => 10,
'chartSpacingBottom' => 15,
'chartSpacingLeft' => 0,
'chartAlignTicks' => FALSE,
'chartBackgroundColorLinearGradient' => array(0, 0, 0, 300),
'chartBackgroundColorStops' => array(array(0, 'rgb(217, 217, 217)'), array(1, 'rgb(255, 255, 255)')),
'title' => 'Monthly Sales Summary',
'titleAlign' => 'left',
'titleFloating' => TRUE,
'titleStyleFont' => '18px Metrophobic, Arial, sans-serif',
'titleStyleColor' => '#0099ff',
'titleX' => 20,
'titleY' => 20,
'legendEnabled' => TRUE,
'legendLayout' => 'horizontal',
'legendAlign' => 'center',
'legendVerticalAlign ' => 'bottom',
'legendItemStyle' => array('color' => '#222'),
'legendBackgroundColorLinearGradient' => array(0, 0, 0, 25),
'legendBackgroundColorStops' => array(array(0, 'rgb(217, 217, 217)'), array(1, 'rgb(255, 255, 255)')),
'tooltipEnabled' => FALSE,
// 'tooltipBackgroundColorLinearGradient' => array(0,0,0,50), // triggers js error
// 'tooltipBackgroundColorStops' => array(array(0,'rgb(217, 217, 217)'),array(1,'rgb(255, 255, 255)')),
//'plotOptionsLinePointStart' => strtotime('-30 day') * 1000,
//'plotOptionsLinePointInterval' => 24 * 3600 * 1000,
//'xAxisType' => 'datetime',
//'xAxisTickInterval' => 10,
//'xAxisStartOnTick' => TRUE,
//'xAxisTickmarkPlacement' => 'on',
//'xAxisTickLength' => 10,
//'xAxisMinorTickLength' => 5,
'xAxisLabelsEnabled' => TRUE,
'xAxisLabelsAlign' => 'right',
'xAxisLabelsStep' => 1,
//'xAxisLabelsRotation' => -35,
'xAxislabelsX' => 5,
'xAxisLabelsY' => 20,
'xAxisCategories' => array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'),
//'yAxisMin' => 0,
//'yAxisMaxPadding' => 0.2,
//'yAxisEndOnTick' => FALSE,
//'yAxisMinorGridLineWidth' => 0,
//'yAxisMinorTickInterval' => 'auto',
//'yAxisMinorTickLength' => 1,
//'yAxisTickLength' => 2,
//'yAxisMinorTickWidth' => 1,
'yAxisTitleText' => 'Temperature °C',
//'yAxisTitleAlign' => 'high',
//'yAxisTitleStyleFont' => '14px Metrophobic, Arial, sans-serif',
//'yAxisTitleRotation' => 0,
//'yAxisTitleX' => 0,
//'yAxisTitleY' => -10,
//'yAxisPlotLines' => array( array('color' => '#808080', 'width' => 1, 'value' => 0 )),
// autostep options
'enableAutoStep' => FALSE
)
);

$series = $this->Highcharts->addChartSeries();

$series->addName('Temperatures')
->addData($this->columnrangechartData);

$mychart->addSeries($series);

$this->set(compact('chartName'));
}

public function line() {

$chartName = 'Line Chart';
Expand Down
32 changes: 32 additions & 0 deletions Vendor/HighRollerColumnrangeChart.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

/**
* Author: ThomsonIT
* Date: 6/2/15
* Time: 8:31 AM
* Desc: HighRoller Columnrange Chart SubClass
*
* Licensed to Gravity.com under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership. Gravity.com licenses this file to you use
* under the Apache License, Version 2.0 (the License); you may not this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
class HighRollerColumnrangeChart extends HighRoller {

public function __construct() {
parent::__construct();
$this->chart->type = 'columnrange';
}

}
23 changes: 23 additions & 0 deletions View/SingleSeriesDemo/columnrange.ctp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
/**
* CakePHP Highcharts Plugin
*
* Copyright (C) 2014 Kurn La Montagne / destinydriven
* <https://github.com/destinydriven>
*
* Multi-licensed under:
* MPL <http://www.mozilla.org/MPL/MPL-1.1.html>
* LGPL <http://www.gnu.org/licenses/lgpl.html>
* GPL <http://www.gnu.org/licenses/gpl.html>
* Apache License, Version 2.0 <http://www.apache.org/licenses/LICENSE-2.0.html>
*/
?>
<div class="chart">
<h4>Columnrange Chart</h4>

<div id="columnrangewrapper" style="display: block; float: left; width:90%; margin-bottom: 20px;"></div>
<div class="clear"></div>

<?php echo $this->Highcharts->render($chartName); ?>

</div>

0 comments on commit eab57d0

Please sign in to comment.