Forum


Replies: 2   Views: 185
Color symbol of line chart
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 deweb  · 12-06-2024 - 08:14

Good morning
I created a lineChart type chart with 2 line series.
The chart works great. However, I try to customize the colors. I can modify the color of the line, but I cannot modify the color of the point (symbol).
I still have a PHP error:

Call to a member function setAttribute() on null

FCPATH/phpdocx/classes/CreateGraphic.php at line 919

I have a premium version and here are my chart settings :
$data = array(
                                'legend' => array('Serie 1', 'Serie 2'),
                                'data' => 
                                        array(
                                                array(
                                                        'name' => '2024',
                                                        'values' => array(42, 31),
                                                ),
                                                array(
                                                        'name' => '2025',
                                                        'values' => array(50, 20),
                                                ),
                                                array(
                                                        'name' => '2026',
                                                        'values' => array(45, 32),
                                                ),
                                                array(
                                                        'name' => '2027',
                                                        'values' => array(48, 34),
                                                ),
                                                array(
                                                        'name' => '2028',
                                                        'values' => array(53, 37),
                                                ),
                                                array(
                                                        'name' => '2029',
                                                        'values' => array(49, 36),
                                                ),
                                                array(
                                                        'name' => '2030',
                                                        'values' => array(54, 28),
                                                ),
                                                array(
                                                        'name' => '2031',
                                                        'values' => array(54, 31),
                                                ),
                                                array(
                                                        'name' => '2032',
                                                        'values' => array(50, 36),
                                                ),
                                                array(
                                                        'name' => '2033',
                                                        'values' => array(47, 24),
                                                ),
                                        ),
                                );
                
                        $paramsChart = array(
                                'data'                  => $data,
                                'type'                  => 'lineChart',
                                'symbol'                => 'dot',
                                'symbolSize'    => 5,
                                'smooth'                => false,
                                'returnChart'   => true,
                                'color'                 => 2,
                                'theme'                 => array(
                                                                         'serRgbColors' => array('00b546','fa7d0f'),
                                                                         'valueRgbColors' => 
                                                                                                array(
                                                                                                         array('00b546','fa7d0f'),
                                                                                                         array('00b546','fa7d0f'),
                                                                                                         array('00b546','fa7d0f'),
                                                                                                         array('00b546','fa7d0f'),
                                                                                                         array('00b546','fa7d0f'),
                                                                                                         array('00b546','fa7d0f'),
                                                                                                         array('00b546','fa7d0f'),
                                                                                                         array('00b546','fa7d0f'),
                                                                                                         array('00b546','fa7d0f'),
                                                                                                         array('00b546','fa7d0f')
                                                                                                ),                                                                      
                                                                                        ),
                        );
Thanks for your help
Pierre

 

Posted by admin  · 12-06-2024 - 09:12

Hello,

The current stable version of phpdocx doesn't include an option to set custom color symbols. A new option must be added (symbolRgbColors or a similar option name). It's currently being developed and it will be included in the next stable release of phpdocx (there's no release date).

Regarding the PHP error you get, it comes from a not supported theme option when generating combo charts. In this case, please do not create custom color for values, only for series:

$paramsChart = array(
    'data' => $data,
    'type' => 'lineChart',
    'symbol' => 'dot',
    'symbolSize' => 5,
    'smooth' => false,
    'returnChart' => true,
    'color' => 2,
    'theme' => array(
        'serRgbColors' => array('00b546','fa7d0f'),
    ),
);

We have opened a task to the dev team to support setting custom color to individual values when adding a combo chart.

Regards.

Posted by deweb  · 12-06-2024 - 14:23

Thank you for your reply !
I'm going to disable the symbols in the meantime!
Good day !
 
Pierre