mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-08-30 03:59:11 +00:00
5d5e550342
* Additional Support for Chart DataSeriesValues Fix #2863. DataSeriesValues now extends Properties, allowing it to share code in common with Axis and Gridlines. This causes some minor breakages; in particular line width is now initialized to null instead of Excel's default value, and is specified in points, as the user would expect from Excel, rather than the value stored in Xml. This change: - adds support for 1 or 2 marker colors. - adds support for `smoothLine` to DataSeriesValues. - will determine `catAx` or `valAx` for Axis based on what is read from the Xml when available, rather than guessing based on format. (Another minor break.) - reads `formatCode` and `sourceLinked` for Axis. - correct 2 uses of `$plotSeriesRef` to `$plotSeriesIndex` in Writer/Xlsx/Chart. - pushes coverage over 90% for Chart (88.70% overall). * Update Change Log I had updated previously but forgot to stage the member. * Adopt Some Suggestions Incorporate some changes suggested by @bridgeplayr. * Use ChartColor for DSV Fill And Font Text DataSeriesValues Fill could be a scalar or an array, so I saved it till last. * Some Final Cleanup No code changes. Illustrate even more of the new features in existing sample files. Deprecate *_ARGB in Properties/ChartColors in favor of *_RGB, because it uses only 6 hex digits. The alpha value is stored separately.
213 lines
6.2 KiB
PHP
213 lines
6.2 KiB
PHP
<?php
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Chart;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Chart\Axis;
|
|
use PhpOffice\PhpSpreadsheet\Chart\GridLines;
|
|
use PhpOffice\PhpSpreadsheet\Chart\Properties;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class ShadowPresetsTest extends TestCase
|
|
{
|
|
public function testGridlineShadowPresets(): void
|
|
{
|
|
$gridlines = new GridLines();
|
|
$gridlines->setShadowProperties(17);
|
|
$expectedShadow = [
|
|
'effect' => 'innerShdw',
|
|
'distance' => 4,
|
|
'direction' => 270,
|
|
'blur' => 5,
|
|
];
|
|
foreach ($expectedShadow as $key => $value) {
|
|
self::assertEquals($gridlines->getShadowProperty($key), $value, $key);
|
|
}
|
|
}
|
|
|
|
public function testGridlineShadowPresetsWithArray(): void
|
|
{
|
|
$gridlines = new GridLines();
|
|
$gridlines->setShadowProperties(20);
|
|
$expectedShadow = [
|
|
'effect' => 'outerShdw',
|
|
'blur' => 6,
|
|
'direction' => 315,
|
|
'size' => [
|
|
'sx' => null,
|
|
'sy' => 0.23,
|
|
'kx' => -20,
|
|
'ky' => null,
|
|
],
|
|
'algn' => 'bl',
|
|
'rotWithShape' => '0',
|
|
];
|
|
foreach ($expectedShadow as $key => $value) {
|
|
self::assertEquals($gridlines->getShadowProperty($key), $value, $key);
|
|
}
|
|
}
|
|
|
|
public function testAxisShadowPresets(): void
|
|
{
|
|
$axis = new Axis();
|
|
$axis->setShadowProperties(9);
|
|
$expectedShadow = [
|
|
'effect' => 'outerShdw',
|
|
'blur' => 4,
|
|
'distance' => 3,
|
|
'direction' => 225,
|
|
'algn' => 'br',
|
|
'rotWithShape' => '0',
|
|
];
|
|
foreach ($expectedShadow as $key => $value) {
|
|
self::assertEquals($axis->getShadowProperty($key), $value, $key);
|
|
}
|
|
}
|
|
|
|
public function testAxisShadowPresetsWithChanges(): void
|
|
{
|
|
$axis = new Axis();
|
|
$axis->setShadowProperties(
|
|
9, // preset
|
|
'FF0000', // colorValue
|
|
'srgbClr', // colorType
|
|
20, // alpha
|
|
6, // blur
|
|
30, // direction
|
|
4, // distance
|
|
);
|
|
$expectedShadow = [
|
|
'effect' => 'outerShdw',
|
|
'blur' => 6,
|
|
'distance' => 4,
|
|
'direction' => 30,
|
|
'algn' => 'br',
|
|
'rotWithShape' => '0',
|
|
'color' => [
|
|
'value' => 'FF0000',
|
|
'type' => 'srgbClr',
|
|
'alpha' => 20,
|
|
],
|
|
];
|
|
foreach ($expectedShadow as $key => $value) {
|
|
self::assertEquals($axis->getShadowProperty($key), $value, $key);
|
|
}
|
|
}
|
|
|
|
public function testGridlinesShadowPresetsWithChanges(): void
|
|
{
|
|
$gridline = new GridLines();
|
|
$gridline->setShadowProperties(
|
|
9, // preset
|
|
'FF0000', // colorValue
|
|
'srgbClr', // colorType
|
|
20, // alpha
|
|
6, // blur
|
|
30, // direction
|
|
4, // distance
|
|
);
|
|
$expectedShadow = [
|
|
'effect' => 'outerShdw',
|
|
'blur' => 6,
|
|
'distance' => 4,
|
|
'direction' => 30,
|
|
'algn' => 'br',
|
|
'rotWithShape' => '0',
|
|
'color' => [
|
|
'value' => 'FF0000',
|
|
'type' => 'srgbClr',
|
|
'alpha' => 20,
|
|
],
|
|
];
|
|
foreach ($expectedShadow as $key => $value) {
|
|
self::assertEquals($gridline->getShadowProperty($key), $value, $key);
|
|
}
|
|
}
|
|
|
|
public function testPreset0(): void
|
|
{
|
|
$axis = new Axis();
|
|
$axis->setShadowProperties(0);
|
|
$expectedShadow = [
|
|
'presets' => Properties::SHADOW_PRESETS_NOSHADOW,
|
|
'effect' => null,
|
|
'color' => [
|
|
'type' => Properties::EXCEL_COLOR_TYPE_STANDARD,
|
|
'value' => 'black',
|
|
'alpha' => 40,
|
|
],
|
|
'size' => [
|
|
'sx' => null,
|
|
'sy' => null,
|
|
'kx' => null,
|
|
'ky' => null,
|
|
],
|
|
'blur' => null,
|
|
'direction' => null,
|
|
'distance' => null,
|
|
'algn' => null,
|
|
'rotWithShape' => null,
|
|
];
|
|
foreach ($expectedShadow as $key => $value) {
|
|
self::assertEquals($value, $axis->getShadowProperty($key), $key);
|
|
}
|
|
}
|
|
|
|
public function testOutOfRangePresets(): void
|
|
{
|
|
$axis = new Axis();
|
|
$axis->setShadowProperties(99);
|
|
$expectedShadow = [
|
|
'presets' => Properties::SHADOW_PRESETS_NOSHADOW,
|
|
'effect' => null,
|
|
'color' => [
|
|
'type' => Properties::EXCEL_COLOR_TYPE_STANDARD,
|
|
'value' => 'black',
|
|
'alpha' => 40,
|
|
],
|
|
'size' => [
|
|
'sx' => null,
|
|
'sy' => null,
|
|
'kx' => null,
|
|
'ky' => null,
|
|
],
|
|
'blur' => null,
|
|
'direction' => null,
|
|
'distance' => null,
|
|
'algn' => null,
|
|
'rotWithShape' => null,
|
|
];
|
|
foreach ($expectedShadow as $key => $value) {
|
|
self::assertEquals($value, $axis->getShadowProperty($key), $key);
|
|
}
|
|
}
|
|
|
|
public function testOutOfRangeGridlines(): void
|
|
{
|
|
$gridline = new GridLines();
|
|
$gridline->setShadowProperties(99);
|
|
$expectedShadow = [
|
|
'presets' => Properties::SHADOW_PRESETS_NOSHADOW,
|
|
'effect' => null,
|
|
'color' => [
|
|
'type' => Properties::EXCEL_COLOR_TYPE_STANDARD,
|
|
'value' => 'black',
|
|
'alpha' => 40,
|
|
],
|
|
'size' => [
|
|
'sx' => null,
|
|
'sy' => null,
|
|
'kx' => null,
|
|
'ky' => null,
|
|
],
|
|
'blur' => null,
|
|
'direction' => null,
|
|
'distance' => null,
|
|
'algn' => null,
|
|
'rotWithShape' => null,
|
|
];
|
|
foreach ($expectedShadow as $key => $value) {
|
|
self::assertEquals($value, $gridline->getShadowProperty($key), $key);
|
|
}
|
|
}
|
|
}
|