--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;
}
}

View File

@ -25,7 +25,6 @@
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Writer_Excel2007_Chart
*
@ -33,21 +32,25 @@
* @package PHPExcel_Writer_Excel2007
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPart
{
class PHPExcel_Writer_Excel2007_Chart extends
PHPExcel_Writer_Excel2007_WriterPart {
/**
* Write charts to XML format
*
* @param PHPExcel_Chart $pChart
*
* @return string XML Output
* @throws PHPExcel_Writer_Exception
*/
public function writeChart(PHPExcel_Chart $pChart = null)
{
public function writeChart(PHPExcel_Chart $pChart = NULL) {
// Create XML writer
$objWriter = null;
if ($this->getParentWriter()->getUseDiskCaching()) {
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
$objWriter = NULL;
if ($this->getParentWriter()
->getUseDiskCaching()
) {
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()
->getDiskCachingDirectory());
} else {
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
}
@ -83,16 +86,20 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->writeAttribute('val', 0);
$objWriter->endElement();
$this->_writePlotArea($pChart->getPlotArea(),
$this->_writePlotArea(
$pChart->getPlotArea(),
$pChart->getXAxisLabel(),
$pChart->getYAxisLabel(),
$objWriter,
$pChart->getWorksheet()
$pChart->getWorksheet(),
$pChart->getChartAxisX(),
$pChart->getChartAxisY(),
$pChart->getMajorGridlines(),
$pChart->getMinorGridlines()
);
$this->_writeLegend($pChart->getLegend(), $objWriter);
$objWriter->startElement('c:plotVisOnly');
$objWriter->writeAttribute('val', 1);
$objWriter->endElement();
@ -120,10 +127,10 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
*
* @param PHPExcel_Chart_Title $title
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
*
* @throws PHPExcel_Writer_Exception
*/
private function _writeTitle(PHPExcel_Chart_Title $title = null, $objWriter)
{
private function _writeTitle(PHPExcel_Chart_Title $title = NULL, $objWriter) {
if (is_null($title)) {
return;
}
@ -141,9 +148,12 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->startElement('a:p');
$caption = $title->getCaption();
if ((is_array($caption)) && (count($caption) > 0))
if ((is_array($caption)) && (count($caption) > 0)) {
$caption = $caption[0];
$this->getParentWriter()->getWriterPart('stringtable')->writeRichTextForCharts($objWriter, $caption, 'a');
}
$this->getParentWriter()
->getWriterPart('stringtable')
->writeRichTextForCharts($objWriter, $caption, 'a');
$objWriter->endElement();
$objWriter->endElement();
@ -164,10 +174,10 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
*
* @param PHPExcel_Chart_Legend $legend
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
*
* @throws PHPExcel_Writer_Exception
*/
private function _writeLegend(PHPExcel_Chart_Legend $legend = null, $objWriter)
{
private function _writeLegend(PHPExcel_Chart_Legend $legend = NULL, $objWriter) {
if (is_null($legend)) {
return;
}
@ -216,15 +226,22 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
* @param PHPExcel_Chart_PlotArea $plotArea
* @param PHPExcel_Chart_Title $xAxisLabel
* @param PHPExcel_Chart_Title $yAxisLabel
* @param PHPExcel_Chart_Axis $xAxis
* @param PHPExcel_Chart_Axis $yAxis
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
*
* @throws PHPExcel_Writer_Exception
*/
private function _writePlotArea(PHPExcel_Chart_PlotArea $plotArea,
PHPExcel_Chart_Title $xAxisLabel = NULL,
PHPExcel_Chart_Title $yAxisLabel = NULL,
$objWriter,
PHPExcel_Worksheet $pSheet)
{
PHPExcel_Worksheet $pSheet,
PHPExcel_Chart_Axis $xAxis,
PHPExcel_Chart_Axis $yAxis,
PHPExcel_Chart_Gridlines $majorGridlines,
PHPExcel_Chart_Gridlines $minorGridlines
) {
if (is_null($plotArea)) {
return;
}
@ -273,14 +290,16 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->writeAttribute('val', (integer) $plotGroup->getSmoothLine());
$objWriter->endElement();
} elseif (($chartType === PHPExcel_Chart_DataSeries::TYPE_BARCHART) ||
($chartType === PHPExcel_Chart_DataSeries::TYPE_BARCHART_3D)) {
($chartType === PHPExcel_Chart_DataSeries::TYPE_BARCHART_3D)
) {
$objWriter->startElement('c:gapWidth');
$objWriter->writeAttribute('val', 150);
$objWriter->endElement();
if ($plotGroupingType == 'percentStacked' ||
$plotGroupingType == 'stacked') {
$plotGroupingType == 'stacked'
) {
$objWriter->startElement('c:overlap');
$objWriter->writeAttribute('val', 100);
@ -325,7 +344,8 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
if (($chartType !== PHPExcel_Chart_DataSeries::TYPE_PIECHART) &&
($chartType !== PHPExcel_Chart_DataSeries::TYPE_PIECHART_3D) &&
($chartType !== PHPExcel_Chart_DataSeries::TYPE_DONUTCHART)) {
($chartType !== PHPExcel_Chart_DataSeries::TYPE_DONUTCHART)
) {
$objWriter->startElement('c:axId');
$objWriter->writeAttribute('val', $id1);
@ -351,15 +371,16 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
if (($chartType !== PHPExcel_Chart_DataSeries::TYPE_PIECHART) &&
($chartType !== PHPExcel_Chart_DataSeries::TYPE_PIECHART_3D) &&
($chartType !== PHPExcel_Chart_DataSeries::TYPE_DONUTCHART)) {
($chartType !== PHPExcel_Chart_DataSeries::TYPE_DONUTCHART)
) {
if ($chartType === PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) {
$this->_writeValAx($objWriter,$plotArea,$xAxisLabel,$chartType,$id1,$id2,$catIsMultiLevelSeries);
$this->_writeValAx($objWriter, $plotArea, $xAxisLabel, $chartType, $id1, $id2, $catIsMultiLevelSeries, $xAxis, $yAxis, $majorGridlines, $minorGridlines);
} else {
$this->_writeCatAx($objWriter,$plotArea,$xAxisLabel,$chartType,$id1,$id2,$catIsMultiLevelSeries);
$this->_writeCatAx($objWriter, $plotArea, $xAxisLabel, $chartType, $id1, $id2, $catIsMultiLevelSeries, $xAxis, $yAxis);
}
$this->_writeValAx($objWriter,$plotArea,$yAxisLabel,$chartType,$id1,$id2,$valIsMultiLevelSeries);
$this->_writeValAx($objWriter, $plotArea, $yAxisLabel, $chartType, $id1, $id2, $valIsMultiLevelSeries, $xAxis, $yAxis, $majorGridlines, $minorGridlines);
}
$objWriter->endElement();
@ -370,10 +391,10 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
*
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
* @param PHPExcel_Chart_Layout $chartLayout Chart layout
*
* @throws PHPExcel_Writer_Exception
*/
private function _writeDataLbls($objWriter, $chartLayout)
{
private function _writeDataLbls($objWriter, $chartLayout) {
$objWriter->startElement('c:dLbls');
$objWriter->startElement('c:showLegendKey');
@ -381,7 +402,6 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->writeAttribute('val', ((empty($showLegendKey)) ? 0 : 1));
$objWriter->endElement();
$objWriter->startElement('c:showVal');
$showVal = (empty($chartLayout)) ? 0 : $chartLayout->getShowVal();
$objWriter->writeAttribute('val', ((empty($showVal)) ? 0 : 1));
@ -425,10 +445,10 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
* @param string $id1
* @param string $id2
* @param boolean $isMultiLevelSeries
*
* @throws PHPExcel_Writer_Exception
*/
private function _writeCatAx($objWriter, PHPExcel_Chart_PlotArea $plotArea, $xAxisLabel, $groupType, $id1, $id2, $isMultiLevelSeries)
{
private function _writeCatAx($objWriter, PHPExcel_Chart_PlotArea $plotArea, $xAxisLabel, $groupType, $id1, $id2, $isMultiLevelSeries, $xAxis, $yAxis) {
$objWriter->startElement('c:catAx');
if ($id1 > 0) {
@ -439,7 +459,7 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->startElement('c:scaling');
$objWriter->startElement('c:orientation');
$objWriter->writeAttribute('val', "minMax");
$objWriter->writeAttribute('val', $yAxis->getAxisOptionsProperty('orientation'));
$objWriter->endElement();
$objWriter->endElement();
@ -466,8 +486,9 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->startElement('a:r');
$caption = $xAxisLabel->getCaption();
if (is_array($caption))
if (is_array($caption)) {
$caption = $caption[0];
}
$objWriter->startElement('a:t');
// $objWriter->writeAttribute('xml:space', 'preserve');
$objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML($caption));
@ -490,20 +511,20 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
}
$objWriter->startElement('c:numFmt');
$objWriter->writeAttribute('formatCode', "General");
$objWriter->writeAttribute('sourceLinked', 1);
$objWriter->writeAttribute('formatCode', $yAxis->getAxisNumberFormat());
$objWriter->writeAttribute('sourceLinked', $yAxis->getAxisNumberSourceLinked());
$objWriter->endElement();
$objWriter->startElement('c:majorTickMark');
$objWriter->writeAttribute('val', "out");
$objWriter->writeAttribute('val', $yAxis->getAxisOptionsProperty('major_tick_mark'));
$objWriter->endElement();
$objWriter->startElement('c:minorTickMark');
$objWriter->writeAttribute('val', "none");
$objWriter->writeAttribute('val', $yAxis->getAxisOptionsProperty('minor_tick_mark'));
$objWriter->endElement();
$objWriter->startElement('c:tickLblPos');
$objWriter->writeAttribute('val', "nextTo");
$objWriter->writeAttribute('val', $yAxis->getAxisOptionsProperty('axis_labels'));
$objWriter->endElement();
if ($id2 > 0) {
@ -512,7 +533,7 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->endElement();
$objWriter->startElement('c:crosses');
$objWriter->writeAttribute('val', "autoZero");
$objWriter->writeAttribute('val', $yAxis->getAxisOptionsProperty('horizontal_crosses'));
$objWriter->endElement();
}
@ -534,10 +555,8 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->endElement();
}
$objWriter->endElement();
}
/**
* Write Value Axis
*
@ -548,10 +567,10 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
* @param string $id1
* @param string $id2
* @param boolean $isMultiLevelSeries
*
* @throws PHPExcel_Writer_Exception
*/
private function _writeValAx($objWriter, PHPExcel_Chart_PlotArea $plotArea, $yAxisLabel, $groupType, $id1, $id2, $isMultiLevelSeries)
{
private function _writeValAx($objWriter, PHPExcel_Chart_PlotArea $plotArea, $yAxisLabel, $groupType, $id1, $id2, $isMultiLevelSeries, $xAxis, $yAxis, $majorGridlines, $minorGridlines) {
$objWriter->startElement('c:valAx');
if ($id2 > 0) {
@ -562,7 +581,20 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->startElement('c:scaling');
$objWriter->startElement('c:orientation');
$objWriter->writeAttribute('val', "minMax");
$objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('orientation'));
if (!is_null($xAxis->getAxisOptionsProperty('maximum'))) {
$objWriter->startElement('c:max');
$objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('maximum'));
$objWriter->endElement();
}
if (!is_null($xAxis->getAxisOptionsProperty('minimum'))) {
$objWriter->startElement('c:min');
$objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('minimum'));
$objWriter->endElement();
}
$objWriter->endElement();
$objWriter->endElement();
@ -575,9 +607,220 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->endElement();
$objWriter->startElement('c:majorGridlines');
$objWriter->startElement('c:spPr');
if (!is_null($majorGridlines->getLineColorProperty('value'))) {
$objWriter->startElement('a:ln');
$objWriter->writeAttribute('w', $majorGridlines->getLineStyleProperty('width'));
$objWriter->startElement('a:solidFill');
$objWriter->startElement("a:{$majorGridlines->getLineColorProperty('type')}");
$objWriter->writeAttribute('val', $majorGridlines->getLineColorProperty('value'));
$objWriter->startElement('a:alpha');
$objWriter->writeAttribute('val', $majorGridlines->getLineColorProperty('alpha'));
$objWriter->endElement(); //end alpha
$objWriter->endElement(); //end srgbClr
$objWriter->endElement(); //end solidFill
$objWriter->startElement('a:prstDash');
$objWriter->writeAttribute('val', $majorGridlines->getLineStyleProperty('dash'));
$objWriter->endElement();
if ($majorGridlines->getLineStyleProperty('join') == 'miter') {
$objWriter->startElement('a:miter');
$objWriter->writeAttribute('lim', '800000');
$objWriter->endElement();
} else {
$objWriter->startElement('a:bevel');
$objWriter->endElement();
}
if (!is_null($majorGridlines->getLineStyleProperty(['arrow', 'head', 'type']))) {
$objWriter->startElement('a:headEnd');
$objWriter->writeAttribute('type', $majorGridlines->getLineStyleProperty(['arrow', 'head', 'type']));
$objWriter->writeAttribute('w', $majorGridlines->getLineStyleArrowParameters('head', 'w'));
$objWriter->writeAttribute('len', $majorGridlines->getLineStyleArrowParameters('head', 'len'));
$objWriter->endElement();
}
if (!is_null($majorGridlines->getLineStyleProperty(['arrow', 'end', 'type']))) {
$objWriter->startElement('a:tailEnd');
$objWriter->writeAttribute('type', $majorGridlines->getLineStyleProperty(['arrow', 'end', 'type']));
$objWriter->writeAttribute('w', $majorGridlines->getLineStyleArrowParameters('end', 'w'));
$objWriter->writeAttribute('len', $majorGridlines->getLineStyleArrowParameters('end', 'len'));
$objWriter->endElement();
}
$objWriter->endElement(); //end ln
}
$objWriter->startElement('a:effectLst');
if (!is_null($majorGridlines->getGlowSize())) {
$objWriter->startElement('a:glow');
$objWriter->writeAttribute('rad', $majorGridlines->getGlowSize());
$objWriter->startElement("a:{$majorGridlines->getGlowColor('type')}");
$objWriter->writeAttribute('val', $majorGridlines->getGlowColor('value'));
$objWriter->startElement('a:alpha');
$objWriter->writeAttribute('val', $majorGridlines->getGlowColor('alpha'));
$objWriter->endElement(); //end alpha
$objWriter->endElement(); //end schemeClr
$objWriter->endElement(); //end glow
}
if (!is_null($majorGridlines->getShadowProperty('presets'))) {
$objWriter->startElement("a:{$majorGridlines->getShadowProperty('effect')}");
if (!is_null($majorGridlines->getShadowProperty('blur'))) {
$objWriter->writeAttribute('blurRad', $majorGridlines->getShadowProperty('blur'));
}
if (!is_null($majorGridlines->getShadowProperty('distance'))) {
$objWriter->writeAttribute('dist', $majorGridlines->getShadowProperty('distance'));
}
if (!is_null($majorGridlines->getShadowProperty('direction'))) {
$objWriter->writeAttribute('dir', $majorGridlines->getShadowProperty('direction'));
}
if (!is_null($majorGridlines->getShadowProperty('algn'))) {
$objWriter->writeAttribute('algn', $majorGridlines->getShadowProperty('algn'));
}
if (!is_null($majorGridlines->getShadowProperty(['size', 'sx']))) {
$objWriter->writeAttribute('sx', $majorGridlines->getShadowProperty(['size', 'sx']));
}
if (!is_null($majorGridlines->getShadowProperty(['size', 'sy']))) {
$objWriter->writeAttribute('sy', $majorGridlines->getShadowProperty(['size', 'sy']));
}
if (!is_null($majorGridlines->getShadowProperty(['size', 'kx']))) {
$objWriter->writeAttribute('kx', $majorGridlines->getShadowProperty(['size', 'kx']));
}
if (!is_null($majorGridlines->getShadowProperty('rotWithShape'))) {
$objWriter->writeAttribute('rotWithShape', $majorGridlines->getShadowProperty('rotWithShape'));
}
$objWriter->startElement("a:{$majorGridlines->getShadowProperty(['color', 'type'])}");
$objWriter->writeAttribute('val', $majorGridlines->getShadowProperty(['color', 'value']));
$objWriter->startElement('a:alpha');
$objWriter->writeAttribute('val', $majorGridlines->getShadowProperty(['color', 'alpha']));
$objWriter->endElement(); //end alpha
$objWriter->endElement(); //end color:type
$objWriter->endElement(); //end shadow
}
if (!is_null($majorGridlines->getSoftEdgesSize())) {
$objWriter->startElement('a:softEdge');
$objWriter->writeAttribute('rad', $majorGridlines->getSoftEdgesSize());
$objWriter->endElement(); //end softEdge
}
$objWriter->endElement(); //end effectLst
$objWriter->endElement(); //end spPr
$objWriter->endElement(); //end majorGridLines
if ($minorGridlines->getObjectState()) {
$objWriter->startElement('c:minorGridlines');
$objWriter->startElement('c:spPr');
if (!is_null($minorGridlines->getLineColorProperty('value'))) {
$objWriter->startElement('a:ln');
$objWriter->writeAttribute('w', $minorGridlines->getLineStyleProperty('width'));
$objWriter->startElement('a:solidFill');
$objWriter->startElement("a:{$minorGridlines->getLineColorProperty('type')}");
$objWriter->writeAttribute('val', $minorGridlines->getLineColorProperty('value'));
$objWriter->startElement('a:alpha');
$objWriter->writeAttribute('val', $minorGridlines->getLineColorProperty('alpha'));
$objWriter->endElement(); //end alpha
$objWriter->endElement(); //end srgbClr
$objWriter->endElement(); //end solidFill
$objWriter->startElement('a:prstDash');
$objWriter->writeAttribute('val', $minorGridlines->getLineStyleProperty('dash'));
$objWriter->endElement();
if ($minorGridlines->getLineStyleProperty('join') == 'miter') {
$objWriter->startElement('a:miter');
$objWriter->writeAttribute('lim', '800000');
$objWriter->endElement();
} else {
$objWriter->startElement('a:bevel');
$objWriter->endElement();
}
if (!is_null($minorGridlines->getLineStyleProperty(['arrow', 'head', 'type']))) {
$objWriter->startElement('a:headEnd');
$objWriter->writeAttribute('type', $minorGridlines->getLineStyleProperty(['arrow', 'head', 'type']));
$objWriter->writeAttribute('w', $minorGridlines->getLineStyleArrowParameters('head', 'w'));
$objWriter->writeAttribute('len', $minorGridlines->getLineStyleArrowParameters('head', 'len'));
$objWriter->endElement();
}
if (!is_null($minorGridlines->getLineStyleProperty(['arrow', 'end', 'type']))) {
$objWriter->startElement('a:tailEnd');
$objWriter->writeAttribute('type', $minorGridlines->getLineStyleProperty(['arrow', 'end', 'type']));
$objWriter->writeAttribute('w', $minorGridlines->getLineStyleArrowParameters('end', 'w'));
$objWriter->writeAttribute('len', $minorGridlines->getLineStyleArrowParameters('end', 'len'));
$objWriter->endElement();
}
$objWriter->endElement(); //end ln
}
$objWriter->startElement('a:effectLst');
if (!is_null($minorGridlines->getGlowSize())) {
$objWriter->startElement('a:glow');
$objWriter->writeAttribute('rad', $minorGridlines->getGlowSize());
$objWriter->startElement("a:{$minorGridlines->getGlowColor('type')}");
$objWriter->writeAttribute('val', $minorGridlines->getGlowColor('value'));
$objWriter->startElement('a:alpha');
$objWriter->writeAttribute('val', $minorGridlines->getGlowColor('alpha'));
$objWriter->endElement(); //end alpha
$objWriter->endElement(); //end schemeClr
$objWriter->endElement(); //end glow
}
if (!is_null($minorGridlines->getShadowProperty('presets'))) {
$objWriter->startElement("a:{$minorGridlines->getShadowProperty('effect')}");
if (!is_null($minorGridlines->getShadowProperty('blur'))) {
$objWriter->writeAttribute('blurRad', $minorGridlines->getShadowProperty('blur'));
}
if (!is_null($minorGridlines->getShadowProperty('distance'))) {
$objWriter->writeAttribute('dist', $minorGridlines->getShadowProperty('distance'));
}
if (!is_null($minorGridlines->getShadowProperty('direction'))) {
$objWriter->writeAttribute('dir', $minorGridlines->getShadowProperty('direction'));
}
if (!is_null($minorGridlines->getShadowProperty('algn'))) {
$objWriter->writeAttribute('algn', $minorGridlines->getShadowProperty('algn'));
}
if (!is_null($minorGridlines->getShadowProperty(['size', 'sx']))) {
$objWriter->writeAttribute('sx', $minorGridlines->getShadowProperty(['size', 'sx']));
}
if (!is_null($minorGridlines->getShadowProperty(['size', 'sy']))) {
$objWriter->writeAttribute('sy', $minorGridlines->getShadowProperty(['size', 'sy']));
}
if (!is_null($minorGridlines->getShadowProperty(['size', 'kx']))) {
$objWriter->writeAttribute('kx', $minorGridlines->getShadowProperty(['size', 'kx']));
}
if (!is_null($minorGridlines->getShadowProperty('rotWithShape'))) {
$objWriter->writeAttribute('rotWithShape', $minorGridlines->getShadowProperty('rotWithShape'));
}
$objWriter->startElement("a:{$minorGridlines->getShadowProperty(['color', 'type'])}");
$objWriter->writeAttribute('val', $minorGridlines->getShadowProperty(['color', 'value']));
$objWriter->startElement('a:alpha');
$objWriter->writeAttribute('val', $minorGridlines->getShadowProperty(['color', 'alpha']));
$objWriter->endElement(); //end alpha
$objWriter->endElement(); //end color:type
$objWriter->endElement(); //end shadow
}
if (!is_null($minorGridlines->getSoftEdgesSize())) {
$objWriter->startElement('a:softEdge');
$objWriter->writeAttribute('rad', $minorGridlines->getSoftEdgesSize());
$objWriter->endElement(); //end softEdge
}
$objWriter->endElement(); //end effectLst
$objWriter->endElement(); //end spPr
$objWriter->endElement(); //end minorGridLines
}
if (!is_null($yAxisLabel)) {
$objWriter->startElement('c:title');
$objWriter->startElement('c:tx');
$objWriter->startElement('c:rich');
@ -592,8 +835,10 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->startElement('a:r');
$caption = $yAxisLabel->getCaption();
if (is_array($caption))
if (is_array($caption)) {
$caption = $caption[0];
}
$objWriter->startElement('a:t');
// $objWriter->writeAttribute('xml:space', 'preserve');
$objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML($caption));
@ -617,34 +862,175 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
}
$objWriter->startElement('c:numFmt');
$objWriter->writeAttribute('formatCode', "General");
$objWriter->writeAttribute('sourceLinked', 1);
$objWriter->writeAttribute('formatCode', $xAxis->getAxisNumberFormat());
$objWriter->writeAttribute('sourceLinked', $xAxis->getAxisNumberSourceLinked());
$objWriter->endElement();
$objWriter->startElement('c:majorTickMark');
$objWriter->writeAttribute('val', "out");
$objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('major_tick_mark'));
$objWriter->endElement();
$objWriter->startElement('c:minorTickMark');
$objWriter->writeAttribute('val', "none");
$objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('minor_tick_mark'));
$objWriter->endElement();
$objWriter->startElement('c:tickLblPos');
$objWriter->writeAttribute('val', "nextTo");
$objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('axis_labels'));
$objWriter->endElement();
$objWriter->startElement('c:spPr');
if (!is_null($xAxis->getFillProperty('value'))) {
$objWriter->startElement('a:solidFill');
$objWriter->startElement("a:" . $xAxis->getFillProperty('type'));
$objWriter->writeAttribute('val', $xAxis->getFillProperty('value'));
$objWriter->startElement('a:alpha');
$objWriter->writeAttribute('val', $xAxis->getFillProperty('alpha'));
$objWriter->endElement();
$objWriter->endElement();
$objWriter->endElement();
}
$objWriter->startElement('a:ln');
$objWriter->writeAttribute('w', $xAxis->getLineStyleProperty('width'));
$objWriter->writeAttribute('cap', $xAxis->getLineStyleProperty('cap'));
$objWriter->writeAttribute('cmpd', $xAxis->getLineStyleProperty('compound'));
if (!is_null($xAxis->getLineProperty('value'))) {
$objWriter->startElement('a:solidFill');
$objWriter->startElement("a:" . $xAxis->getLineProperty('type'));
$objWriter->writeAttribute('val', $xAxis->getLineProperty('value'));
$objWriter->startElement('a:alpha');
$objWriter->writeAttribute('val', $xAxis->getLineProperty('alpha'));
$objWriter->endElement();
$objWriter->endElement();
$objWriter->endElement();
}
$objWriter->startElement('a:prstDash');
$objWriter->writeAttribute('val', $xAxis->getLineStyleProperty('dash'));
$objWriter->endElement();
if ($xAxis->getLineStyleProperty('join') == 'miter') {
$objWriter->startElement('a:miter');
$objWriter->writeAttribute('lim', '800000');
$objWriter->endElement();
} else {
$objWriter->startElement('a:bevel');
$objWriter->endElement();
}
if (!is_null($xAxis->getLineStyleProperty(['arrow', 'head', 'type']))) {
$objWriter->startElement('a:headEnd');
$objWriter->writeAttribute('type', $xAxis->getLineStyleProperty(['arrow', 'head', 'type']));
$objWriter->writeAttribute('w', $xAxis->getLineStyleArrowWidth('head'));
$objWriter->writeAttribute('len', $xAxis->getLineStyleArrowLength('head'));
$objWriter->endElement();
}
if (!is_null($xAxis->getLineStyleProperty(['arrow', 'end', 'type']))) {
$objWriter->startElement('a:tailEnd');
$objWriter->writeAttribute('type', $xAxis->getLineStyleProperty(['arrow', 'end', 'type']));
$objWriter->writeAttribute('w', $xAxis->getLineStyleArrowWidth('end'));
$objWriter->writeAttribute('len', $xAxis->getLineStyleArrowLength('end'));
$objWriter->endElement();
}
$objWriter->endElement();
$objWriter->startElement('a:effectLst');
if (!is_null($xAxis->getGlowProperty('size'))) {
$objWriter->startElement('a:glow');
$objWriter->writeAttribute('rad', $xAxis->getGlowProperty('size'));
$objWriter->startElement("a:{$xAxis->getGlowProperty(['color','type'])}");
$objWriter->writeAttribute('val', $xAxis->getGlowProperty(['color','value']));
$objWriter->startElement('a:alpha');
$objWriter->writeAttribute('val', $xAxis->getGlowProperty(['color','alpha']));
$objWriter->endElement();
$objWriter->endElement();
$objWriter->endElement();
}
if (!is_null($xAxis->getShadowProperty('presets'))) {
$objWriter->startElement("a:{$xAxis->getShadowProperty('effect')}");
if (!is_null($xAxis->getShadowProperty('blur'))) {
$objWriter->writeAttribute('blurRad', $xAxis->getShadowProperty('blur'));
}
if (!is_null($xAxis->getShadowProperty('distance'))) {
$objWriter->writeAttribute('dist', $xAxis->getShadowProperty('distance'));
}
if (!is_null($xAxis->getShadowProperty('direction'))) {
$objWriter->writeAttribute('dir', $xAxis->getShadowProperty('direction'));
}
if (!is_null($xAxis->getShadowProperty('algn'))) {
$objWriter->writeAttribute('algn', $xAxis->getShadowProperty('algn'));
}
if (!is_null($xAxis->getShadowProperty(['size','sx']))) {
$objWriter->writeAttribute('sx', $xAxis->getShadowProperty(['size','sx']));
}
if (!is_null($xAxis->getShadowProperty(['size','sy']))) {
$objWriter->writeAttribute('sy', $xAxis->getShadowProperty(['size','sy']));
}
if (!is_null($xAxis->getShadowProperty(['size','kx']))) {
$objWriter->writeAttribute('kx', $xAxis->getShadowProperty(['size','kx']));
}
if (!is_null($xAxis->getShadowProperty('rotWithShape'))) {
$objWriter->writeAttribute('rotWithShape', $xAxis->getShadowProperty('rotWithShape'));
}
$objWriter->startElement("a:{$xAxis->getShadowProperty(['color','type'])}");
$objWriter->writeAttribute('val', $xAxis->getShadowProperty(['color','value']));
$objWriter->startElement('a:alpha');
$objWriter->writeAttribute('val', $xAxis->getShadowProperty(['color','alpha']));
$objWriter->endElement();
$objWriter->endElement();
$objWriter->endElement();
}
if (!is_null($xAxis->getSoftEdgesSize())) {
$objWriter->startElement('a:softEdge');
$objWriter->writeAttribute('rad', $xAxis->getSoftEdgesSize());
$objWriter->endElement();
}
$objWriter->endElement(); //effectList
$objWriter->endElement(); //end spPr
if ($id1 > 0) {
$objWriter->startElement('c:crossAx');
$objWriter->writeAttribute('val', $id2);
$objWriter->endElement();
$objWriter->startElement('c:crosses');
$objWriter->writeAttribute('val', "autoZero");
if (!is_null($xAxis->getAxisOptionsProperty('horizontal_crosses_value'))) {
$objWriter->startElement('c:crossesAt');
$objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('horizontal_crosses_value'));
$objWriter->endElement();
} else {
$objWriter->startElement('c:crosses');
$objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('horizontal_crosses'));
$objWriter->endElement();
}
$objWriter->startElement('c:crossBetween');
$objWriter->writeAttribute('val', "midCat");
$objWriter->endElement();
if (!is_null($xAxis->getAxisOptionsProperty('major_unit'))) {
$objWriter->startElement('c:majorUnit');
$objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('major_unit'));
$objWriter->endElement();
}
if (!is_null($xAxis->getAxisOptionsProperty('minor_unit'))) {
$objWriter->startElement('c:minorUnit');
$objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('minor_unit'));
$objWriter->endElement();
}
}
if ($isMultiLevelSeries) {
@ -654,28 +1040,33 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->endElement();
}
}
$objWriter->endElement();
}
/**
* Get the data series type(s) for a chart plot series
*
* @param PHPExcel_Chart_PlotArea $plotArea
*
* @return string|array
* @throws PHPExcel_Writer_Exception
*/
private static function _getChartType($plotArea)
{
private
static function _getChartType($plotArea) {
$groupCount = $plotArea->getPlotGroupCount();
if ($groupCount == 1) {
$chartType = array($plotArea->getPlotGroupByIndex(0)->getPlotType());
$chartType = array(
$plotArea->getPlotGroupByIndex(0)
->getPlotType()
);
} else {
$chartTypes = array();
for ($i = 0; $i < $groupCount; ++$i) {
$chartTypes[] = $plotArea->getPlotGroupByIndex($i)->getPlotType();
$chartTypes[] = $plotArea->getPlotGroupByIndex($i)
->getPlotType();
}
$chartType = array_unique($chartTypes);
if (count($chartTypes) == 0) {
@ -696,6 +1087,7 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
* @param boolean &$valIsMultiLevelSeries Is value set a multi-series set
* @param string &$plotGroupingType Type of grouping for multi-series values
* @param PHPExcel_Worksheet $pSheet
*
* @throws PHPExcel_Writer_Exception
*/
private function _writePlotGroup($plotGroup,
@ -705,14 +1097,14 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
&$valIsMultiLevelSeries,
&$plotGroupingType,
PHPExcel_Worksheet $pSheet
)
{
) {
if (is_null($plotGroup)) {
return;
}
if (($groupType == PHPExcel_Chart_DataSeries::TYPE_BARCHART) ||
($groupType == PHPExcel_Chart_DataSeries::TYPE_BARCHART_3D)) {
($groupType == PHPExcel_Chart_DataSeries::TYPE_BARCHART_3D)
) {
$objWriter->startElement('c:barDir');
$objWriter->writeAttribute('val', $plotGroup->getPlotDirection());
$objWriter->endElement();
@ -730,13 +1122,15 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
$plotSeriesCount = count($plotSeriesOrder);
if (($groupType !== PHPExcel_Chart_DataSeries::TYPE_RADARCHART) &&
($groupType !== PHPExcel_Chart_DataSeries::TYPE_STOCKCHART)) {
($groupType !== PHPExcel_Chart_DataSeries::TYPE_STOCKCHART)
) {
if ($groupType !== PHPExcel_Chart_DataSeries::TYPE_LINECHART) {
if (($groupType == PHPExcel_Chart_DataSeries::TYPE_PIECHART) ||
($groupType == PHPExcel_Chart_DataSeries::TYPE_PIECHART_3D) ||
($groupType == PHPExcel_Chart_DataSeries::TYPE_DONUTCHART) ||
($plotSeriesCount > 1)) {
($plotSeriesCount > 1)
) {
$objWriter->startElement('c:varyColors');
$objWriter->writeAttribute('val', 1);
$objWriter->endElement();
@ -761,7 +1155,8 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
if (($groupType == PHPExcel_Chart_DataSeries::TYPE_PIECHART) ||
($groupType == PHPExcel_Chart_DataSeries::TYPE_PIECHART_3D) ||
($groupType == PHPExcel_Chart_DataSeries::TYPE_DONUTCHART)) {
($groupType == PHPExcel_Chart_DataSeries::TYPE_DONUTCHART)
) {
$objWriter->startElement('c:dPt');
$objWriter->startElement('c:idx');
@ -794,7 +1189,8 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
// Formatting for the points
if (($groupType == PHPExcel_Chart_DataSeries::TYPE_LINECHART) ||
($groupType == PHPExcel_Chart_DataSeries::TYPE_STOCKCHART)) {
($groupType == PHPExcel_Chart_DataSeries::TYPE_STOCKCHART)
) {
$objWriter->startElement('c:spPr');
$objWriter->startElement('a:ln');
$objWriter->writeAttribute('w', 12700);
@ -820,13 +1216,15 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->writeAttribute('val', 3);
$objWriter->endElement();
}
$objWriter->endElement();
}
}
if (($groupType === PHPExcel_Chart_DataSeries::TYPE_BARCHART) ||
($groupType === PHPExcel_Chart_DataSeries::TYPE_BARCHART_3D) ||
($groupType === PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART)) {
($groupType === PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART)
) {
$objWriter->startElement('c:invertIfNegative');
$objWriter->writeAttribute('val', 0);
@ -840,7 +1238,8 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
if (($groupType == PHPExcel_Chart_DataSeries::TYPE_PIECHART) ||
($groupType == PHPExcel_Chart_DataSeries::TYPE_PIECHART_3D) ||
($groupType == PHPExcel_Chart_DataSeries::TYPE_DONUTCHART)) {
($groupType == PHPExcel_Chart_DataSeries::TYPE_DONUTCHART)
) {
if (!is_null($plotGroup->getPlotStyle())) {
$plotStyle = $plotGroup->getPlotStyle();
@ -853,7 +1252,8 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
}
if (($groupType === PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) ||
($groupType === PHPExcel_Chart_DataSeries::TYPE_SCATTERCHART)) {
($groupType === PHPExcel_Chart_DataSeries::TYPE_SCATTERCHART)
) {
$objWriter->startElement('c:xVal');
} else {
$objWriter->startElement('c:cat');
@ -868,7 +1268,8 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
$valIsMultiLevelSeries = $valIsMultiLevelSeries || $plotSeriesValues->isMultiLevelSeries();
if (($groupType === PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) ||
($groupType === PHPExcel_Chart_DataSeries::TYPE_SCATTERCHART)) {
($groupType === PHPExcel_Chart_DataSeries::TYPE_SCATTERCHART)
) {
$objWriter->startElement('c:yVal');
} else {
$objWriter->startElement('c:val');
@ -894,10 +1295,10 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
*
* @param PHPExcel_Chart_DataSeriesValues $plotSeriesLabel
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
*
* @throws PHPExcel_Writer_Exception
*/
private function _writePlotSeriesLabel($plotSeriesLabel, $objWriter)
{
private function _writePlotSeriesLabel($plotSeriesLabel, $objWriter) {
if (is_null($plotSeriesLabel)) {
return;
}
@ -932,6 +1333,7 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
* @param string $groupType Type of plot for dataseries
* @param string $dataType Datatype of series values
* @param PHPExcel_Worksheet $pSheet
*
* @throws PHPExcel_Writer_Exception
*/
private function _writePlotSeriesValues($plotSeriesValues,
@ -939,8 +1341,7 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
$groupType,
$dataType = 'str',
PHPExcel_Worksheet $pSheet
)
{
) {
if (is_null($plotSeriesValues)) {
return;
}
@ -992,10 +1393,12 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
if (($groupType != PHPExcel_Chart_DataSeries::TYPE_PIECHART) &&
($groupType != PHPExcel_Chart_DataSeries::TYPE_PIECHART_3D) &&
($groupType != PHPExcel_Chart_DataSeries::TYPE_DONUTCHART)) {
($groupType != PHPExcel_Chart_DataSeries::TYPE_DONUTCHART)
) {
if (($plotSeriesValues->getFormatCode() !== NULL) &&
($plotSeriesValues->getFormatCode() !== '')) {
($plotSeriesValues->getFormatCode() !== '')
) {
$objWriter->startElement('c:formatCode');
$objWriter->writeRawData($plotSeriesValues->getFormatCode());
$objWriter->endElement();
@ -1032,10 +1435,10 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
*
* @param PHPExcel_Chart_DataSeriesValues $plotSeriesValues
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
*
* @throws PHPExcel_Writer_Exception
*/
private function _writeBubbles($plotSeriesValues, $objWriter, PHPExcel_Worksheet $pSheet)
{
private function _writeBubbles($plotSeriesValues, $objWriter, PHPExcel_Worksheet $pSheet) {
if (is_null($plotSeriesValues)) {
return;
}
@ -1078,10 +1481,10 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
*
* @param PHPExcel_Chart_Layout $layout
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
*
* @throws PHPExcel_Writer_Exception
*/
private function _writeLayout(PHPExcel_Chart_Layout $layout = NULL, $objWriter)
{
private function _writeLayout(PHPExcel_Chart_Layout $layout = NULL, $objWriter) {
$objWriter->startElement('c:layout');
if (!is_null($layout)) {
@ -1146,10 +1549,10 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
* Write Alternate Content block
*
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
*
* @throws PHPExcel_Writer_Exception
*/
private function _writeAlternateContent($objWriter)
{
private function _writeAlternateContent($objWriter) {
$objWriter->startElement('mc:AlternateContent');
$objWriter->writeAttribute('xmlns:mc', 'http://schemas.openxmlformats.org/markup-compatibility/2006');
@ -1175,10 +1578,10 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
* Write Printer Settings
*
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
*
* @throws PHPExcel_Writer_Exception
*/
private function _writePrintSettings($objWriter)
{
private function _writePrintSettings($objWriter) {
$objWriter->startElement('c:printSettings');
$objWriter->startElement('c:headerFooter');