Forum


Replies: 1   Views: 153
More on charts

Posted by Siegfried  · 11-09-2019 - 12:42

hello supportteam,

currently I have to add some charts to my document and I have 3 questions on which I didn't find an answer in the forum respective the API documentation.

 

1. For me it is very important to give each data-element of a pie- oder bar-chart a seperate color which I read from a database. Is there a way to do it like the following codesample illustrates (which maybe overules the color-property of the addChart-parameters)

If there is no way yet, would it be possible to add this as a feature in a later version of phpdocx?

$data = array(
    'data' => array(
        array(
            'name' => 'Legend 1',
            'values' => array(20),
            'color' => 'ff0000',
        ),
        array(
            'name' => 'Legend 2',
            'values' => array(30),
            'color' => '00ff00',        
        ),
        array(
            'name' => 'Legend 3',
            'values' => array(40),
            'color' => '0000ff',
        ),
    ),
);

2. Is it possible to style the font of the legend (which font, size, color, attributes like bold, italic) ? The size is very important for me because of people with vision impairment.

3. Which are the possible Values for the formatCode - property of the addChart() - method? I didn't find any description or samples.

thanks in advance

Siegfried


 

 

Posted by admin  · 12-09-2019 - 08:33

Edited by admin · 13-09-2019 - 08:22

Hello,

Setting custom colors for series and values will be added in phpdocx 9.5 for Premium licenses (there's no release date yet). The current version only supports using MS Word color schemes.

About the second question, phpdocx 9.5 will include options to set horizontalAxis and verticalAxis font sizes, bold and other styles, but changing legend styles isn't included. We have send the request to the dev team, but if you open a ticket (https://www.phpdocx.com/support) the dev team can do the needed changes and send the new classes to your e-mail.

You can find a sample of the formatCode option in the samples included in the package (examples/Core/addChart/sample_16.php):

'formatCode' => '#,##0.00',

As this is a custom string field we recommend you to get the format code string you want to use from MS Word. This is generating a chart using MS Word and setting a new format code, you can copy and paste the value of the field to the formatCode option.

Regards.