Closed Lumimimi closed 3 weeks ago
Yes, there is a way, but I think I need to make it easier. So, even though I am going to tell you how to do it, I want to leave this ticket open while I add the necessary code to simplify it. The following code changes the font name used for the labels, but you can just as easily change the size.
$font = new Font();
$font->setLatin('Times New Roman');
$layoutArray = ['labelFont' => $font];
$layout = new Layout($layoutArray);
Layout
has a labelFont
property and a getLabelFont
method, but no setLabelFont
, so you have to initialize that property in the constructor - I think a set method should be added. I think it's also likely that the writer should use the font name if the Latin name is missing, which would allow users to specify the much more familiar setName
rather than setLatin
.
Thank you very much for your response.
This is:
What is the expected behavior? In PhpSpreadsheet, I would like to be able to set the font size of data labels (both category names and percentages) in a pie chart directly from the PHP code.
What is the current behavior? Currently, there doesn’t seem to be a direct way to modify the font size of pie chart data labels (like category names and percentages) within PhpSpreadsheet. I have reviewed the documentation and tried various settings, but could not find a solution for this.
What are the steps to reproduce? Below is a sample code to generate a pie chart with data labels. However, I cannot find a way to adjust the font size of these labels (category names and values shown on the chart) directly:
If this is an issue with reading a specific spreadsheet file, then it may be appropriate to provide a sample file that demonstrates the problem; but please keep it as small as possible, and sanitize any confidential information before uploading.
What features do you think are causing the issue
Which versions of PhpSpreadsheet and PHP are affected? I am using PhpSpreadsheet version versions : * 3.3.0 and PHP version PHP 8.2.9.