--Added 3 new classes: PHPExcel_Chart_Axis, PHPExcel_Chart_GridLines, PHPExcel_Chart_Properties.php

--Modified Chart.php and Writer/Excel2007/Chart.php for using new classes
--Now it is possible to set some (most of existing) options of Axis, Major Grid-lines and Minor Grid-lines
--No need to use that feature
This commit is contained in:
Wiktor 2014-07-14 16:59:53 +02:00
parent 78a065754d
commit 568038c5bf
5 changed files with 3056 additions and 1168 deletions

View File

@ -98,6 +98,33 @@ class PHPExcel_Chart
*/
private $_displayBlanksAs = '0';
/**
* Chart Asix Y as
*
* @var PHPExcel_Chart_Axis
*/
private $_yAxis = null;
/**
* Chart Asix X as
*
* @var PHPExcel_Chart_Axis
*/
private $_xAxis = null;
/**
* Chart Major Gridlines as
*
* @var PHPExcel_Chart_Gridlines
*/
private $_majorGridlines = null;
/**
* Chart Minor Gridlines as
*
* @var PHPExcel_Chart_Gridlines
*/
private $_minorGridlines = null;
/**
* Top-Left Cell Position
@ -150,7 +177,7 @@ class PHPExcel_Chart
/**
* Create a new PHPExcel_Chart
*/
public function __construct($name, PHPExcel_Chart_Title $title = null, PHPExcel_Chart_Legend $legend = null, PHPExcel_Chart_PlotArea $plotArea = null, $plotVisibleOnly = true, $displayBlanksAs = '0', PHPExcel_Chart_Title $xAxisLabel = null, PHPExcel_Chart_Title $yAxisLabel = null)
public function __construct($name, PHPExcel_Chart_Title $title = null, PHPExcel_Chart_Legend $legend = null, PHPExcel_Chart_PlotArea $plotArea = null, $plotVisibleOnly = true, $displayBlanksAs = '0', PHPExcel_Chart_Title $xAxisLabel = null, PHPExcel_Chart_Title $yAxisLabel = null, PHPExcel_Chart_Axis $xAxis = null, PHPExcel_Chart_Axis $yAxis = null, PHPExcel_Chart_Gridlines $majorGridlines = null, PHPExcel_Chart_Gridlines $minorGridlines = null)
{
$this->_name = $name;
$this->_title = $title;
@ -160,6 +187,10 @@ class PHPExcel_Chart
$this->_plotArea = $plotArea;
$this->_plotVisibleOnly = $plotVisibleOnly;
$this->_displayBlanksAs = $displayBlanksAs;
$this->_xAxis = $xAxis;
$this->_yAxis = $yAxis;
$this->_majorGridlines = $majorGridlines;
$this->_minorGridlines = $minorGridlines;
}
/**
@ -327,6 +358,59 @@ class PHPExcel_Chart
}
/**
* Get yAxis
*
* @return PHPExcel_Chart_Axis
*/
public function getChartAxisY() {
if($this->_yAxis !== NULL){
return $this->_yAxis;
}
return new PHPExcel_Chart_Axis();
}
/**
* Get xAxis
*
* @return PHPExcel_Chart_Axis
*/
public function getChartAxisX() {
if($this->_xAxis !== NULL){
return $this->_xAxis;
}
return new PHPExcel_Chart_Axis();
}
/**
* Get Major Gridlines
*
* @return PHPExcel_Chart_Gridlines
*/
public function getMajorGridlines() {
if($this->_majorGridlines !== NULL){
return $this->_majorGridlines;
}
return new PHPExcel_Chart_Gridlines();
}
/**
* Get Minor Gridlines
*
* @return PHPExcel_Chart_Gridlines
*/
public function getMinorGridlines() {
if($this->_minorGridlines !== NULL){
return $this->_minorGridlines;
}
return new PHPExcel_Chart_Gridlines();
}
/**
* Set the Top Left position for the chart
*

View File

@ -0,0 +1,584 @@
<?php
require_once 'Properties.php';
/**
* Created by PhpStorm.
* User: Wiktor Trzonkowski
* Date: 6/17/14
* Time: 12:11 PM
*/
class PHPExcel_Chart_Axis extends
PHPExcel_Properties {
/**
* Axis Number
*
* @var array of mixed
*/
private
$_axis_number = array(
'format' => self::FORMAT_CODE_GENERAL,
'source_linked' => 1
);
/**
* Axis Options
*
* @var array of mixed
*/
private $_axis_options = array(
'minimum' => NULL,
'maximum' => NULL,
'major_unit' => NULL,
'minor_unit' => NULL,
'orientation' => self::ORIENTATION_NORMAL,
'minor_tick_mark' => self::TICK_MARK_NONE,
'major_tick_mark' => self::TICK_MARK_NONE,
'axis_labels' => self::AXIS_LABELS_NEXT_TO,
'horizontal_crosses' => self::HORIZONTAL_CROSSES_AUTOZERO,
'horizontal_crosses_value' => NULL
);
/**
* Fill Properties
*
* @var array of mixed
*/
private $_fill_properties = array(
'type' => self::EXCEL_COLOR_TYPE_ARGB,
'value' => NULL,
'alpha' => 0
);
/**
* Line Properties
*
* @var array of mixed
*/
private $_line_properties = array(
'type' => self::EXCEL_COLOR_TYPE_ARGB,
'value' => NULL,
'alpha' => 0
);
/**
* Line Style Properties
*
* @var array of mixed
*/
private $_line_style_properties = array(
'width' => '9525',
'compound' => self::LINE_STYLE_COMPOUND_SIMPLE,
'dash' => self::LINE_STYLE_DASH_SOLID,
'cap' => self::LINE_STYLE_CAP_FLAT,
'join' => self::LINE_STYLE_JOIN_BEVEL,
'arrow' => array(
'head' => array(
'type' => self::LINE_STYLE_ARROW_TYPE_NOARROW,
'size' => self::LINE_STYLE_ARROW_SIZE_5
),
'end' => array(
'type' => self::LINE_STYLE_ARROW_TYPE_NOARROW,
'size' => self::LINE_STYLE_ARROW_SIZE_8
),
)
);
/**
* Shadow Properties
*
* @var array of mixed
*/
private $_shadow_properties = array(
'presets' => self::SHADOW_PRESETS_NOSHADOW,
'effect' => NULL,
'color' => array(
'type' => self::EXCEL_COLOR_TYPE_STANDARD,
'value' => 'black',
'alpha' => 40,
),
'size' => array(
'sx' => NULL,
'sy' => NULL,
'kx' => NULL
),
'blur' => NULL,
'direction' => NULL,
'distance' => NULL,
'algn' => NULL,
'rotWithShape' => NULL
);
/**
* Glow Properties
*
* @var array of mixed
*/
private $_glow_properties = array(
'size' => NULL,
'color' => array(
'type' => self::EXCEL_COLOR_TYPE_STANDARD,
'value' => 'black',
'alpha' => 40
)
);
/**
* Soft Edge Properties
*
* @var array of mixed
*/
private $_soft_edges = array(
'size' => NULL
);
/**
* Get Series Data Type
*
* @return string
*/
public function setAxisNumberProperties($format_code) {
$this->_axis_number['format'] = (string) $format_code;
$this->_axis_number['source_linked'] = 0;
}
/**
* Get Axis Number Format Data Type
*
* @return string
*/
public function getAxisNumberFormat() {
return $this->_axis_number['format'];
}
/**
* Get Axis Number Source Linked
*
* @return string
*/
public function getAxisNumberSourceLinked() {
return (string) $this->_axis_number['source_linked'];
}
/**
* Set Axis Options Properties
*
* @param string $axis_labels
* @param string $horizontal_crosses_value
* @param string $horizontal_crosses
* @param string $axis_orientation
* @param string $major_tmt
* @param string $minor_tmt
* @param string $minimum
* @param string $maximum
* @param string $major_unit
* @param string $minor_unit
*
*/
public function setAxisOptionsProperties($axis_labels, $horizontal_crosses_value = NULL, $horizontal_crosses = NULL,
$axis_orientation = NULL, $major_tmt = NULL, $minor_tmt = NULL, $minimum = NULL, $maximum = NULL, $major_unit = NULL,
$minor_unit = NULL) {
$this->_axis_options['axis_labels'] = (string) $axis_labels;
($horizontal_crosses_value !== NULL)
? $this->_axis_options['horizontal_crosses_value'] = (string) $horizontal_crosses_value : NULL;
($horizontal_crosses !== NULL) ? $this->_axis_options['horizontal_crosses'] = (string) $horizontal_crosses : NULL;
($axis_orientation !== NULL) ? $this->_axis_options['orientation'] = (string) $axis_orientation : NULL;
($major_tmt !== NULL) ? $this->_axis_options['major_tick_mark'] = (string) $major_tmt : NULL;
($minor_tmt !== NULL) ? $this->_axis_options['minor_tick_mark'] = (string) $minor_tmt : NULL;
($minor_tmt !== NULL) ? $this->_axis_options['minor_tick_mark'] = (string) $minor_tmt : NULL;
($minimum !== NULL) ? $this->_axis_options['minimum'] = (string) $minimum : NULL;
($maximum !== NULL) ? $this->_axis_options['maximum'] = (string) $maximum : NULL;
($major_unit !== NULL) ? $this->_axis_options['major_unit'] = (string) $major_unit : NULL;
($minor_unit !== NULL) ? $this->_axis_options['minor_unit'] = (string) $minor_unit : NULL;
}
/**
* Get Axis Options Property
*
* @param string $property
*
* @return string
*/
public function getAxisOptionsProperty($property) {
return $this->_axis_options[$property];
}
/**
* Set Axis Orientation Property
*
* @param string $orientation
*
*/
public function setAxisOrientation($orientation) {
$this->orientation = (string) $orientation;
}
/**
* Set Fill Property
*
* @param string $color
* @param int $alpha
* @param string $type
*
*/
public function setFillParameters($color, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_ARGB) {
$this->_fill_properties = $this->setColorProperties($color, $alpha, $type);
}
/**
* Set Line Property
*
* @param string $color
* @param int $alpha
* @param string $type
*
*/
public function setLineParameters($color, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_ARGB) {
$this->_line_properties = $this->setColorProperties($color, $alpha, $type);
}
/**
* Get Fill Property
*
* @param string $property
*
* @return string
*/
public function getFillProperty($property) {
return $this->_fill_properties[$property];
}
/**
* Get Line Property
*
* @param string $property
*
* @return string
*/
public function getLineProperty($property) {
return $this->_line_properties[$property];
}
/**
* Set Line Style Properties
*
* @param float $line_width
* @param string $compound_type
* @param string $dash_type
* @param string $cap_type
* @param string $join_type
* @param string $head_arrow_type
* @param string $head_arrow_size
* @param string $end_arrow_type
* @param string $end_arrow_size
*
*/
public function setLineStyleProperties($line_width = NULL, $compound_type = NULL,
$dash_type = NULL, $cap_type = NULL, $join_type = NULL, $head_arrow_type = NULL,
$head_arrow_size = NULL, $end_arrow_type = NULL, $end_arrow_size = NULL) {
(!is_null($line_width)) ? $this->_line_style_properties['width'] = $this->getExcelPointsWidth((float) $line_width)
: NULL;
(!is_null($compound_type)) ? $this->_line_style_properties['compound'] = (string) $compound_type : NULL;
(!is_null($dash_type)) ? $this->_line_style_properties['dash'] = (string) $dash_type : NULL;
(!is_null($cap_type)) ? $this->_line_style_properties['cap'] = (string) $cap_type : NULL;
(!is_null($join_type)) ? $this->_line_style_properties['join'] = (string) $join_type : NULL;
(!is_null($head_arrow_type)) ? $this->_line_style_properties['arrow']['head']['type'] = (string) $head_arrow_type
: NULL;
(!is_null($head_arrow_size)) ? $this->_line_style_properties['arrow']['head']['size'] = (string) $head_arrow_size
: NULL;
(!is_null($end_arrow_type)) ? $this->_line_style_properties['arrow']['end']['type'] = (string) $end_arrow_type
: NULL;
(!is_null($end_arrow_size)) ? $this->_line_style_properties['arrow']['end']['size'] = (string) $end_arrow_size
: NULL;
}
/**
* Get Line Style Property
*
* @param array|string $elements
*
* @return string
*/
public function getLineStyleProperty($elements) {
return $this->getArrayElementsValue($this->_line_style_properties, $elements);
}
/**
* Get Line Style Arrow Excel Width
*
* @param string $arrow
*
* @return string
*/
public function getLineStyleArrowWidth($arrow) {
return $this->getLineStyleArrowSize($this->_line_style_properties['arrow'][$arrow]['size'], 'w');
}
/**
* Get Line Style Arrow Excel Length
*
* @param string $arrow
*
* @return string
*/
public function getLineStyleArrowLength($arrow) {
return $this->getLineStyleArrowSize($this->_line_style_properties['arrow'][$arrow]['size'], 'len');
}
/**
* Set Shadow Properties
*
* @param int $shadow_presets
* @param string $sh_color_value
* @param string $sh_color_type
* @param string $sh_color_alpha
* @param float $sh_blur
* @param int $sh_angle
* @param float $sh_distance
*
*/
public function setShadowProperties($sh_presets, $sh_color_value = NULL, $sh_color_type = NULL, $sh_color_alpha = NULL, $sh_blur = NULL, $sh_angle = NULL, $sh_distance = NULL) {
$this
->_setShadowPresetsProperties((int) $sh_presets)
->_setShadowColor(
is_null($sh_color_value) ? $this->_shadow_properties['color']['value'] : $sh_color_value
, is_null($sh_color_alpha) ? (int) $this->_shadow_properties['color']['alpha'] : $sh_color_alpha
, is_null($sh_color_type) ? $this->_shadow_properties['color']['type'] : $sh_color_type)
->_setShadowBlur($sh_blur)
->_setShadowAngle($sh_angle)
->_setShadowDistance($sh_distance);
}
/**
* Set Shadow Color
*
* @param int $shadow_presets
*
* @return PHPExcel_Chart_Axis
*/
private function _setShadowPresetsProperties($shadow_presets) {
$this->_shadow_properties['presets'] = $shadow_presets;
$this->_setShadowProperiesMapValues($this->getShadowPresetsMap($shadow_presets));
return $this;
}
/**
* Set Shadow Properties from Maped Values
*
* @param array $properties_map
* @param * $reference
*
* @return PHPExcel_Chart_Axis
*/
private function _setShadowProperiesMapValues(array $properties_map, &$reference = NULL) {
$base_reference = $reference;
foreach ($properties_map as $property_key => $property_val) {
if (is_array($property_val)) {
if ($reference === NULL) {
$reference = & $this->_shadow_properties[$property_key];
} else {
$reference = & $reference[$property_key];
}
$this->_setShadowProperiesMapValues($property_val, $reference);
} else {
if ($base_reference === NULL) {
$this->_shadow_properties[$property_key] = $property_val;
} else {
$reference[$property_key] = $property_val;
}
}
}
return $this;
}
/**
* Set Shadow Color
*
* @param string $color
* @param int $alpha
* @param string $type
*
* @return PHPExcel_Chart_Axis
*/
private function _setShadowColor($color, $alpha, $type) {
$this->_shadow_properties['color'] = $this->setColorProperties($color, $alpha, $type);
return $this;
}
/**
* Set Shadow Blur
*
* @param float $blur
*
* @return PHPExcel_Chart_Axis
*/
private function _setShadowBlur($blur) {
if ($blur !== NULL) {
$this->_shadow_properties['blur'] = (string) $this->getExcelPointsWidth($blur);
}
return $this;
}
/**
* Set Shadow Angle
*
* @param int $angle
*
* @return PHPExcel_Chart_Axis
*/
private function _setShadowAngle($angle) {
if ($angle !== NULL) {
$this->_shadow_properties['direction'] = (string) $this->getExcelPointsAngle($angle);
}
return $this;
}
/**
* Set Shadow Distance
*
* @param float $distance
*
* @return PHPExcel_Chart_Axis
*/
private function _setShadowDistance($distance) {
if ($distance !== NULL) {
$this->_shadow_properties['distance'] = (string) $this->getExcelPointsWidth($distance);
}
return $this;
}
/**
* Get Glow Property
*
* @param float $size
* @param string $color_value
* @param int $color_alpha
* @param string $color_type
*/
public function getShadowProperty($elements) {
return $this->getArrayElementsValue($this->_shadow_properties, $elements);
}
/**
* Set Glow Properties
*
* @param float $size
* @param string $color_value
* @param int $color_alpha
* @param string $color_type
*/
public function setGlowProperties($size, $color_value = NULL, $color_alpha = NULL, $color_type = NULL) {
$this
->_setGlowSize($size)
->_setGlowColor(
is_null($color_value) ? $this->_glow_properties['color']['value'] : $color_value
, is_null($color_alpha) ? (int) $this->_glow_properties['color']['alpha'] : $color_alpha
, is_null($color_type) ? $this->_glow_properties['color']['type'] : $color_type);
}
/**
* Get Glow Property
*
* @param array|string $property
*
* @return string
*/
public function getGlowProperty($property) {
return $this->getArrayElementsValue($this->_glow_properties, $property);
}
/**
* Set Glow Color
*
* @param float $size
*
* @return PHPExcel_Chart_Axis
*/
private function _setGlowSize($size) {
if (!is_null($size)) {
$this->_glow_properties['size'] = $this->getExcelPointsWidth($size);
}
return $this;
}
/**
* Set Glow Color
*
* @param string $color
* @param int $alpha
* @param string $type
*
* @return PHPExcel_Chart_Axis
*/
private function _setGlowColor($color, $alpha, $type) {
$this->_glow_properties['color'] = $this->setColorProperties($color, $alpha, $type);
return $this;
}
/**
* Set Soft Edges Size
*
* @param float $size
*/
public function setSoftEdges($size) {
if (!is_null($size)) {
$_soft_edges['size'] = (string) $this->getExcelPointsWidth($size);
}
}
/**
* Get Soft Edges Size
*
* @return string
*/
public function getSoftEdgesSize() {
return $this->_soft_edges['size'];
}
}

View File

@ -0,0 +1,458 @@
<?php
require_once 'Properties.php';
/**
* Created by PhpStorm.
* User: Wiktor Trzonkowski
* Date: 7/2/14
* Time: 2:36 PM
*/
class PHPExcel_Chart_Gridlines extends
PHPExcel_Properties {
/**
* Properties of Class:
* Object State (State for Minor Tick Mark) @var bool
* Line Properties @var array of mixed
* Shadow Properties @var array of mixed
* Glow Properties @var array of mixed
* Soft Properties @var array of mixed
*
*/
private
$_object_state = FALSE,
$_line_properties = array(
'color' => array(
'type' => self::EXCEL_COLOR_TYPE_STANDARD,
'value' => NULL,
'alpha' => 0
),
'style' => array(
'width' => '9525',
'compound' => self::LINE_STYLE_COMPOUND_SIMPLE,
'dash' => self::LINE_STYLE_DASH_SOLID,
'cap' => self::LINE_STYLE_CAP_FLAT,
'join' => self::LINE_STYLE_JOIN_BEVEL,
'arrow' => array(
'head' => array(
'type' => self::LINE_STYLE_ARROW_TYPE_NOARROW,
'size' => self::LINE_STYLE_ARROW_SIZE_5
),
'end' => array(
'type' => self::LINE_STYLE_ARROW_TYPE_NOARROW,
'size' => self::LINE_STYLE_ARROW_SIZE_8
),
)
)
),
$_shadow_properties = array(
'presets' => self::SHADOW_PRESETS_NOSHADOW,
'effect' => NULL,
'color' => array(
'type' => self::EXCEL_COLOR_TYPE_STANDARD,
'value' => 'black',
'alpha' => 85,
),
'size' => array(
'sx' => NULL,
'sy' => NULL,
'kx' => NULL
),
'blur' => NULL,
'direction' => NULL,
'distance' => NULL,
'algn' => NULL,
'rotWithShape' => NULL
),
$_glow_properties = array(
'size' => NULL,
'color' => array(
'type' => self::EXCEL_COLOR_TYPE_STANDARD,
'value' => 'black',
'alpha' => 40
)
),
$_soft_edges = array(
'size' => NULL
);
/**
* Get Object State
*
* @return bool
*/
public function getObjectState() {
return $this->_object_state;
}
/**
* Change Object State to True
*
* @return PHPExcel_Chart_Gridlines
*/
private function _activateObject() {
$this->_object_state = TRUE;
return $this;
}
/**
* Set Line Color Properties
*
* @param string $value
* @param int $alpha
* @param string $type
*/
public function setLineColorProperties($value, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_STANDARD) {
$this
->_activateObject()
->_line_properties['color'] = $this->setColorProperties(
$value,
$alpha,
$type);
}
/**
* Set Line Color Properties
*
* @param float $line_width
* @param string $compound_type
* @param string $dash_type
* @param string $cap_type
* @param string $join_type
* @param string $head_arrow_type
* @param string $head_arrow_size
* @param string $end_arrow_type
* @param string $end_arrow_size
*/
public function setLineStyleProperties($line_width = NULL, $compound_type = NULL, $dash_type = NULL, $cap_type = NULL, $join_type = NULL, $head_arrow_type = NULL, $head_arrow_size = NULL, $end_arrow_type = NULL, $end_arrow_size = NULL) {
$this->_activateObject();
(!is_null($line_width))
? $this->_line_properties['style']['width'] = $this->getExcelPointsWidth((float) $line_width)
: NULL;
(!is_null($compound_type))
? $this->_line_properties['style']['compound'] = (string) $compound_type
: NULL;
(!is_null($dash_type))
? $this->_line_properties['style']['dash'] = (string) $dash_type
: NULL;
(!is_null($cap_type))
? $this->_line_properties['style']['cap'] = (string) $cap_type
: NULL;
(!is_null($join_type))
? $this->_line_properties['style']['join'] = (string) $join_type
: NULL;
(!is_null($head_arrow_type))
? $this->_line_properties['style']['arrow']['head']['type'] = (string) $head_arrow_type
: NULL;
(!is_null($head_arrow_size))
? $this->_line_properties['style']['arrow']['head']['size'] = (string) $head_arrow_size
: NULL;
(!is_null($end_arrow_type))
? $this->_line_properties['style']['arrow']['end']['type'] = (string) $end_arrow_type
: NULL;
(!is_null($end_arrow_size))
? $this->_line_properties['style']['arrow']['end']['size'] = (string) $end_arrow_size
: NULL;
}
/**
* Get Line Color Property
*
* @param string $parameter
*
* @return string
*/
public function getLineColorProperty($parameter) {
return $this->_line_properties['color'][$parameter];
}
/**
* Get Line Style Property
*
* @param array|string $elements
*
* @return string
*/
public function getLineStyleProperty($elements) {
return $this->getArrayElementsValue($this->_line_properties['style'], $elements);
}
/**
* Set Glow Properties
*
* @param float $size
* @param string $color_value
* @param int $color_alpha
* @param string $color_type
*
*/
public function setGlowProperties($size, $color_value = NULL, $color_alpha = NULL, $color_type = NULL) {
$this
->_activateObject()
->_setGlowSize($size)
->_setGlowColor($color_value, $color_alpha, $color_type);
}
/**
* Get Glow Color Property
*
* @param string $property
*
* @return string
*/
public function getGlowColor($property) {
return $this->_glow_properties['color'][$property];
}
/**
* Get Glow Size
*
* @return string
*/
public function getGlowSize() {
return $this->_glow_properties['size'];
}
/**
* Set Glow Size
*
* @param float $size
*
* @return PHPExcel_Chart_Gridlines
*/
private function _setGlowSize($size) {
$this->_glow_properties['size'] = $this->getExcelPointsWidth((float) $size);
return $this;
}
/**
* Set Glow Color
*
* @param string $color
* @param int $alpha
* @param string $type
*
* @return PHPExcel_Chart_Gridlines
*/
private function _setGlowColor($color, $alpha, $type) {
if (!is_null($color)) {
$this->_glow_properties['color']['value'] = (string) $color;
}
if (!is_null($alpha)) {
$this->_glow_properties['color']['alpha'] = $this->getTrueAlpha((int) $alpha);
}
if (!is_null($type)) {
$this->_glow_properties['color']['type'] = (string) $type;
}
return $this;
}
/**
* Get Line Style Arrow Parameters
*
* @param string $arrow_selector
* @param string $property_selector
*
* @return string
*/
public function getLineStyleArrowParameters($arrow_selector, $property_selector) {
return $this->getLineStyleArrowSize($this->_line_properties['style']['arrow'][$arrow_selector]['size'], $property_selector);
}
/**
* Set Shadow Properties
*
* @param int $sh_presets
* @param string $sh_color_value
* @param string $sh_color_type
* @param int $sh_color_alpha
* @param string $sh_blur
* @param int $sh_angle
* @param float $sh_distance
*
*/
public function setShadowProperties($sh_presets, $sh_color_value = NULL, $sh_color_type = NULL, $sh_color_alpha = NULL, $sh_blur = NULL, $sh_angle = NULL, $sh_distance = NULL) {
$this
->_activateObject()
->_setShadowPresetsProperties((int) $sh_presets)
->_setShadowColor(
is_null($sh_color_value) ? $this->_shadow_properties['color']['value'] : $sh_color_value
, is_null($sh_color_alpha) ? (int) $this->_shadow_properties['color']['alpha']
: $this->getTrueAlpha($sh_color_alpha)
, is_null($sh_color_type) ? $this->_shadow_properties['color']['type'] : $sh_color_type)
->_setShadowBlur($sh_blur)
->_setShadowAngle($sh_angle)
->_setShadowDistance($sh_distance);
}
/**
* Set Shadow Presets Properties
*
* @param int $shadow_presets
*
* @return PHPExcel_Chart_Gridlines
*/
private function _setShadowPresetsProperties($shadow_presets) {
$this->_shadow_properties['presets'] = $shadow_presets;
$this->_setShadowProperiesMapValues($this->getShadowPresetsMap($shadow_presets));
return $this;
}
/**
* Set Shadow Properties Values
*
* @param array $properties_map
* @param * $reference
*
* @return PHPExcel_Chart_Gridlines
*/
private function _setShadowProperiesMapValues(array $properties_map, &$reference = NULL) {
$base_reference = $reference;
foreach ($properties_map as $property_key => $property_val) {
if (is_array($property_val)) {
if ($reference === NULL) {
$reference = & $this->_shadow_properties[$property_key];
} else {
$reference = & $reference[$property_key];
}
$this->_setShadowProperiesMapValues($property_val, $reference);
} else {
if ($base_reference === NULL) {
$this->_shadow_properties[$property_key] = $property_val;
} else {
$reference[$property_key] = $property_val;
}
}
}
return $this;
}
/**
* Set Shadow Color
*
* @param string $color
* @param int $alpha
* @param string $type
*
* @return PHPExcel_Chart_Gridlines
*/
private function _setShadowColor($color, $alpha, $type) {
if (!is_null($color)) {
$this->_shadow_properties['color']['value'] = (string) $color;
}
if (!is_null($alpha)) {
$this->_shadow_properties['color']['alpha'] = $this->getTrueAlpha((int) $alpha);
}
if (!is_null($type)) {
$this->_shadow_properties['color']['type'] = (string) $type;
}
return $this;
}
/**
* Set Shadow Blur
*
* @param float $blur
*
* @return PHPExcel_Chart_Gridlines
*/
private function _setShadowBlur($blur) {
if ($blur !== NULL) {
$this->_shadow_properties['blur'] = (string) $this->getExcelPointsWidth($blur);
}
return $this;
}
/**
* Set Shadow Angle
*
* @param int $angle
*
* @return PHPExcel_Chart_Gridlines
*/
private function _setShadowAngle($angle) {
if ($angle !== NULL) {
$this->_shadow_properties['direction'] = (string) $this->getExcelPointsAngle($angle);
}
return $this;
}
/**
* Set Shadow Distance
*
* @param float $distance
*
* @return PHPExcel_Chart_Gridlines
*/
private function _setShadowDistance($distance) {
if ($distance !== NULL) {
$this->_shadow_properties['distance'] = (string) $this->getExcelPointsWidth($distance);
}
return $this;
}
/**
* Get Shadow Property
*
* @param string $elements
* @param array $elements
*
* @return string
*/
public function getShadowProperty($elements) {
return $this->getArrayElementsValue($this->_shadow_properties, $elements);
}
/**
* Set Soft Edges Size
*
* @param float $size
*/
public function setSoftEdgesSize($size) {
if (!is_null($size)) {
$this->_activateObject();
$_soft_edges['size'] = (string) $this->getExcelPointsWidth($size);
}
}
/**
* Get Soft Edges Size
*
* @return string
*/
public function getSoftEdgesSize() {
return $this->_soft_edges['size'];
}
}

View File

@ -0,0 +1,359 @@
<?php
/**
* Created by PhpStorm.
* User: nhw2h8s
* Date: 7/2/14
* Time: 5:45 PM
*/
abstract class PHPExcel_Properties {
const
EXCEL_COLOR_TYPE_STANDARD = 'prstClr',
EXCEL_COLOR_TYPE_SCHEME = 'schemeClr',
EXCEL_COLOR_TYPE_ARGB = 'srgbClr';
const
AXIS_LABELS_LOW = 'low',
AXIS_LABELS_HIGH = 'high',
AXIS_LABELS_NEXT_TO = 'nextTo',
AXIS_LABELS_NONE = 'none';
const
TICK_MARK_NONE = 'none',
TICK_MARK_INSIDE = 'in',
TICK_MARK_OUTSIDE = 'out',
TICK_MARK_CROSS = 'cross';
const
HORIZONTAL_CROSSES_AUTOZERO = 'autoZero',
HORIZONTAL_CROSSES_MAXIMUM = 'max';
const
FORMAT_CODE_GENERAL = 'General',
FORMAT_CODE_NUMBER = '#,##0.00',
FORMAT_CODE_CURRENCY = '$#,##0.00',
FORMAT_CODE_ACCOUNTING = '_($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)',
FORMAT_CODE_DATE = 'm/d/yyyy',
FORMAT_CODE_TIME = '[$-F400]h:mm:ss AM/PM',
FORMAT_CODE_PERCENTAGE = '0.00%',
FORMAT_CODE_FRACTION = '# ?/?',
FORMAT_CODE_SCIENTIFIC = '0.00E+00',
FORMAT_CODE_TEXT = '@',
FORMAT_CODE_SPECIAL = '00000';
const
ORIENTATION_NORMAL = 'minMax',
ORIENTATION_REVERSED = 'maxMin';
const
LINE_STYLE_COMPOUND_SIMPLE = 'sng',
LINE_STYLE_COMPOUND_DOUBLE = 'dbl',
LINE_STYLE_COMPOUND_THICKTHIN = 'thickThin',
LINE_STYLE_COMPOUND_THINTHICK = 'thinThick',
LINE_STYLE_COMPOUND_TRIPLE = 'tri',
LINE_STYLE_DASH_SOLID = 'solid',
LINE_STYLE_DASH_ROUND_DOT = 'sysDot',
LINE_STYLE_DASH_SQUERE_DOT = 'sysDash',
LINE_STYPE_DASH_DASH = 'dash',
LINE_STYLE_DASH_DASH_DOT = 'dashDot',
LINE_STYLE_DASH_LONG_DASH = 'lgDash',
LINE_STYLE_DASH_LONG_DASH_DOT = 'lgDashDot',
LINE_STYLE_DASH_LONG_DASH_DOT_DOT = 'lgDashDotDot',
LINE_STYLE_CAP_SQUARE = 'sq',
LINE_STYLE_CAP_ROUND = 'rnd',
LINE_STYLE_CAP_FLAT = 'flat',
LINE_STYLE_JOIN_ROUND = 'bevel',
LINE_STYLE_JOIN_MITER = 'miter',
LINE_STYLE_JOIN_BEVEL = 'bevel',
LINE_STYLE_ARROW_TYPE_NOARROW = NULL,
LINE_STYLE_ARROW_TYPE_ARROW = 'triangle',
LINE_STYLE_ARROW_TYPE_OPEN = 'arrow',
LINE_STYLE_ARROW_TYPE_STEALTH = 'stealth',
LINE_STYLE_ARROW_TYPE_DIAMOND = 'diamond',
LINE_STYLE_ARROW_TYPE_OVAL = 'oval',
LINE_STYLE_ARROW_SIZE_1 = 1,
LINE_STYLE_ARROW_SIZE_2 = 2,
LINE_STYLE_ARROW_SIZE_3 = 3,
LINE_STYLE_ARROW_SIZE_4 = 4,
LINE_STYLE_ARROW_SIZE_5 = 5,
LINE_STYLE_ARROW_SIZE_6 = 6,
LINE_STYLE_ARROW_SIZE_7 = 7,
LINE_STYLE_ARROW_SIZE_8 = 8,
LINE_STYLE_ARROW_SIZE_9 = 9;
const
SHADOW_PRESETS_NOSHADOW = NULL,
SHADOW_PRESETS_OUTER_BOTTTOM_RIGHT = 1,
SHADOW_PRESETS_OUTER_BOTTOM = 2,
SHADOW_PRESETS_OUTER_BOTTOM_LEFT = 3,
SHADOW_PRESETS_OUTER_RIGHT = 4,
SHADOW_PRESETS_OUTER_CENTER = 5,
SHADOW_PRESETS_OUTER_LEFT = 6,
SHADOW_PRESETS_OUTER_TOP_RIGHT = 7,
SHADOW_PRESETS_OUTER_TOP = 8,
SHADOW_PRESETS_OUTER_TOP_LEFT = 9,
SHADOW_PRESETS_INNER_BOTTTOM_RIGHT = 10,
SHADOW_PRESETS_INNER_BOTTOM = 11,
SHADOW_PRESETS_INNER_BOTTOM_LEFT = 12,
SHADOW_PRESETS_INNER_RIGHT = 13,
SHADOW_PRESETS_INNER_CENTER = 14,
SHADOW_PRESETS_INNER_LEFT = 15,
SHADOW_PRESETS_INNER_TOP_RIGHT = 16,
SHADOW_PRESETS_INNER_TOP = 17,
SHADOW_PRESETS_INNER_TOP_LEFT = 18,
SHADOW_PRESETS_PERSPECTIVE_BELOW = 19,
SHADOW_PRESETS_PERSPECTIVE_UPPER_RIGHT = 20,
SHADOW_PRESETS_PERSPECTIVE_UPPER_LEFT = 21,
SHADOW_PRESETS_PERSPECTIVE_LOWER_RIGHT = 22,
SHADOW_PRESETS_PERSPECTIVE_LOWER_LEFT = 23;
protected function getExcelPointsWidth($width) {
return $width * 12700;
}
protected function getExcelPointsAngle($angle) {
return $angle * 60000;
}
protected function getTrueAlpha($alpha) {
return (string) 100 - $alpha . '000';
}
protected function setColorProperties($color, $alpha, $type) {
return array(
'type' => (string) $type,
'value' => (string) $color,
'alpha' => (string) $this->getTrueAlpha($alpha)
);
}
protected function getLineStyleArrowSize($array_selector, $array_kay_selector) {
$sizes = array(
1 => array('w' => 'sm', 'len' => 'sm'),
2 => array('w' => 'sm', 'len' => 'med'),
3 => array('w' => 'sm', 'len' => 'lg'),
4 => array('w' => 'med', 'len' => 'sm'),
5 => array('w' => 'med', 'len' => 'med'),
6 => array('w' => 'med', 'len' => 'lg'),
7 => array('w' => 'lg', 'len' => 'sm'),
8 => array('w' => 'lg', 'len' => 'med'),
9 => array('w' => 'lg', 'len' => 'lg')
);
return $sizes[$array_selector][$array_kay_selector];
}
protected function getShadowPresetsMap($shadow_presets_option) {
$presets_options = array(
//OUTER
1 => array(
'effect' => 'outerShdw',
'blur' => '50800',
'distance' => '38100',
'direction' => '2700000',
'algn' => 'tl',
'rotWithShape' => '0'
),
2 => array(
'effect' => 'outerShdw',
'blur' => '50800',
'distance' => '38100',
'direction' => '5400000',
'algn' => 't',
'rotWithShape' => '0'
),
3 => array(
'effect' => 'outerShdw',
'blur' => '50800',
'distance' => '38100',
'direction' => '8100000',
'algn' => 'tr',
'rotWithShape' => '0'
),
4 => array(
'effect' => 'outerShdw',
'blur' => '50800',
'distance' => '38100',
'algn' => 'l',
'rotWithShape' => '0'
),
5 => array(
'effect' => 'outerShdw',
'size' => array(
'sx' => '102000',
'sy' => '102000'
)
,
'blur' => '63500',
'distance' => '38100',
'algn' => 'ctr',
'rotWithShape' => '0'
),
6 => array(
'effect' => 'outerShdw',
'blur' => '50800',
'distance' => '38100',
'direction' => '10800000',
'algn' => 'r',
'rotWithShape' => '0'
),
7 => array(
'effect' => 'outerShdw',
'blur' => '50800',
'distance' => '38100',
'direction' => '18900000',
'algn' => 'bl',
'rotWithShape' => '0'
),
8 => array(
'effect' => 'outerShdw',
'blur' => '50800',
'distance' => '38100',
'direction' => '16200000',
'rotWithShape' => '0'
),
9 => array(
'effect' => 'outerShdw',
'blur' => '50800',
'distance' => '38100',
'direction' => '13500000',
'algn' => 'br',
'rotWithShape' => '0'
),
//INNER
10 => array(
'effect' => 'innerShdw',
'blur' => '63500',
'distance' => '50800',
'direction' => '2700000',
),
11 => array(
'effect' => 'innerShdw',
'blur' => '63500',
'distance' => '50800',
'direction' => '5400000',
),
12 => array(
'effect' => 'innerShdw',
'blur' => '63500',
'distance' => '50800',
'direction' => '8100000',
),
13 => array(
'effect' => 'innerShdw',
'blur' => '63500',
'distance' => '50800',
),
14 => array(
'effect' => 'innerShdw',
'blur' => '114300',
),
15 => array(
'effect' => 'innerShdw',
'blur' => '63500',
'distance' => '50800',
'direction' => '10800000',
),
16 => array(
'effect' => 'innerShdw',
'blur' => '63500',
'distance' => '50800',
'direction' => '18900000',
),
17 => array(
'effect' => 'innerShdw',
'blur' => '63500',
'distance' => '50800',
'direction' => '16200000',
),
18 => array(
'effect' => 'innerShdw',
'blur' => '63500',
'distance' => '50800',
'direction' => '13500000',
),
//perspective
19 => array(
'effect' => 'outerShdw',
'blur' => '152400',
'distance' => '317500',
'size' => array(
'sx' => '90000',
'sy' => '-19000',
),
'direction' => '5400000',
'rotWithShape' => '0',
),
20 => array(
'effect' => 'outerShdw',
'blur' => '76200',
'direction' => '18900000',
'size' => array(
'sy' => '23000',
'kx' => '-1200000',
),
'algn' => 'bl',
'rotWithShape' => '0',
),
21 => array(
'effect' => 'outerShdw',
'blur' => '76200',
'direction' => '13500000',
'size' => array(
'sy' => '23000',
'kx' => '1200000',
),
'algn' => 'br',
'rotWithShape' => '0',
),
22 => array(
'effect' => 'outerShdw',
'blur' => '76200',
'distance' => '12700',
'direction' => '2700000',
'size' => array(
'sy' => '-23000',
'kx' => '-800400',
),
'algn' => 'bl',
'rotWithShape' => '0',
),
23 => array(
'effect' => 'outerShdw',
'blur' => '76200',
'distance' => '12700',
'direction' => '8100000',
'size' => array(
'sy' => '-23000',
'kx' => '800400',
),
'algn' => 'br',
'rotWithShape' => '0',
),
);
return $presets_options[$shadow_presets_option];
}
protected function getArrayElementsValue($properties, $elements) {
$reference = & $properties;
if (!is_array($elements)) {
return $reference[$elements];
} else {
foreach ($elements as $keys) {
$reference = & $reference[$keys];
}
return $reference;
}
return $this;
}
}

File diff suppressed because it is too large Load Diff