Forum


Replies: 7   Views: 312
Serdatalabels - how to use?
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  · 18-05-2024 - 14:31

Hello,

In the Premium package you can find the following samples that use the serDataLabels option: sample_20.php and sample_22.php. For example, from sample_22.php:

$data = array(
    'legend' => array('Series 1', 'Series 2', 'Series 3'),
    'data' => array(
        array(
            'name' => 'data 1',
            'values' => array(10, 7, 5),
        ),
        array(
            'name' => 'data 2',
            'values' => array(20, 60, 3),
        ),
        array(
            'name' => 'data 3',
            'values' => array(50, 33, 7),
        ),
        array(
            'name' => 'data 4',
            'values' => array(25, 0, 14),
        ),
    ),
);
$paramsChart = array(
    'data' => $data,
    'type' => 'lineChart',
    'color' => '5',
    'chartAlign' => 'center',
    'showTable' => 0,
    'sizeX' => 12,
    'sizeY' => 10,
    'legendPos' => 'b',
    'legendOverlay' => '0',
    'haxLabel' => 'X Axis',
    'vaxLabel' => 'Y Axis',
    'haxLabelDisplay' => 'horizontal',
    'vaxLabelDisplay' => 'vertical',
    'hgrid' => '3',
    'vgrid' => '1',
    'theme' => array(
        'serDataLabels' => array(
            array(
                'showValue' => 1,
            ),
            array(
                'showValue' => 1,
            ),
            array(
                'showValue' => 1,
            ),
        ),
    ),
);
$docx->addChart($paramsChart);

And the same sample setting custom formatCode options:

$data = array(
    'legend' => array('Series 1', 'Series 2', 'Series 3'),
    'data' => array(
        array(
            'name' => 'data 1',
            'values' => array(10, 7, 5),
        ),
        array(
            'name' => 'data 2',
            'values' => array(20, 60, 3),
        ),
        array(
            'name' => 'data 3',
            'values' => array(50, 33, 7),
        ),
        array(
            'name' => 'data 4',
            'values' => array(25, 0, 14),
        ),
    ),
);
$paramsChart = array(
    'data' => $data,
    'type' => 'lineChart',
    'color' => '5',
    'chartAlign' => 'center',
    'showTable' => 0,
    'sizeX' => 12,
    'sizeY' => 10,
    'legendPos' => 'b',
    'legendOverlay' => '0',
    'haxLabel' => 'X Axis',
    'vaxLabel' => 'Y Axis',
    'haxLabelDisplay' => 'horizontal',
    'vaxLabelDisplay' => 'vertical',
    'hgrid' => '3',
    'vgrid' => '1',
    'theme' => array(
        'serDataLabels' => array(
            array(
                'showValue' => 1,
                'formatCode' => '#,##0.00',
            ),
            array(
                'showValue' => 1,
                'formatCode' => '##,##0.000',
            ),
            array(
                'showValue' => 1,
                'formatCode' => '#,##0.0000',
            ),
        ),
    ),
);

Please note that a Premium package must be used to apply theme options such as serDataLabels.

Regards.