mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-03 05:57:46 +00:00
6a0d4ff527
Fix #661 (marked stale in 2018, but now reopened). That issue was already mostly resolved by many changes to Xlsx Chart Writer logic some time ago. However, a new problem popped up. PR #2950 added `brightness` logic to Xlsx Reader and Writer. That was done primarily for the benefit of scatter charts. Xlsx Writer writes two brightness properties `lumMod` and `lumOff`. These values are complete complementary (if you know one, you know the other), so I am not sure why both are needed, but my scatter chart testing indicated that they were. It turns out that Radar charts can also set brightness, but, if the writer specifies both `lumMod` and `lumOff`, the resulting chart is slightly off. There may be more to this, but that's all I can deal with for now - I suppress writing `lumOff` if we're writing a radar chart. If there are other problems in this area, I will wait for them to be reported. None of the existing radar chart samples used the brightness properties; however, the example attached to 661 did. It is added as a new Sample, and tests are added.
49 lines
1.5 KiB
PHP
49 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Chart;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Reader\Xlsx as XlsxReader;
|
|
use PhpOffice\PhpSpreadsheet\Shared\File;
|
|
use PhpOffice\PhpSpreadsheet\Writer\Xlsx as XlsxWriter;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class Charts32Radar4Test extends TestCase
|
|
{
|
|
// These tests can only be performed by examining xml.
|
|
// They are based on sample 32readwriteRadarChart4.
|
|
|
|
private string $outputFileName = '';
|
|
|
|
protected function tearDown(): void
|
|
{
|
|
if ($this->outputFileName !== '') {
|
|
unlink($this->outputFileName);
|
|
$this->outputFileName = '';
|
|
}
|
|
}
|
|
|
|
public function test1LummodNoLumoff(): void
|
|
{
|
|
$infile = 'samples/templates/32readwriteRadarChart4.xlsx';
|
|
$reader = new XlsxReader();
|
|
$reader->setIncludeCharts(true);
|
|
$spreadsheet = $reader->load($infile);
|
|
|
|
$writer = new XlsxWriter($spreadsheet);
|
|
$writer->setIncludeCharts(true);
|
|
$this->outputFileName = File::temporaryFilename();
|
|
$writer->save($this->outputFileName);
|
|
$spreadsheet->disconnectWorksheets();
|
|
|
|
$file = 'zip://';
|
|
$file .= $this->outputFileName;
|
|
$file .= '#xl/charts/chart2.xml';
|
|
$data = file_get_contents($file);
|
|
self::assertNotFalse($data);
|
|
self::assertSame(2, substr_count($data, '<a:lumMod'));
|
|
self::assertSame(2, substr_count($data, '<a:lum'), 'should be no lumOff');
|
|
}
|
|
}
|