Forum


Replies: 7   Views: 1723
Docxprem - custom colors for charts
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by admin  · 01-07-2020 - 10:29

Hello,

Please check the following sample included in the package: examples/Core/addChart/sample_18.php that sets custom colors for a pie chart, you can customize them setting valueRgbColors (as pie charts use a single serie with values instead of mutiple series with values) in the same order than the values have been added:

$data = array(
    'data' => array(
        array(
            'name' => 'data 1',
            'values' => array(10),
        ),
        array(
            'name' => 'data 2',
            'values' => array(20),
        ),
        array(
            'name' => 'data 3',
            'values' => array(50),
        ),
        array(
            'name' => 'data 4',
            'values' => array(25),
        ),
    ),
);

$paramsChart = array(
    'data' => $data,
    'type' => 'pieChart',
    'color' => 3,
    'sizeX' => 10,
    'sizeY' => 5,
    'chartAlign' => 'center',
    'theme' => array(
        'valueRgbColors' => array(
            array('99C099', '678CB3', 'ACA42E'),
        ),
    ),
);
$docx->addChart($paramsChart);

Using a Premium license, in this same folder (Core/addChart) you can find 21 samples that illustrate how to use options of the addChart method.

Regards.