Forum


Replies: 4   Views: 95
Custom position to the title in doughnut chart

Posted by anushkapachpute  · 11-12-2024 - 06:05

Hello,

we are using phpdocx premium version 15, I want to generate doughnut charts using addChart. How can I add text to the hole of doughnut chart.

Posted by anushkapachpute  · 11-12-2024 - 07:26

Deleted by admin · 11-12-2024 - 08:26

Posted by admin  · 11-12-2024 - 08:29

Hello,

The stable release of phpdocx only supports adding the chart title in its default position.

We have added a task to support setting a custom layout position to the chart title. This feature will be added in the next stable release of phpdocx.

Regards.

Posted by anushkapachpute  · 11-12-2024 - 10:14

Okay. Can we add the values next to the points in the legend below the doughnut chart?

$data = array(

    'data' => array(

        array(

            'name' => 'Equity',

            'values' => array(67.17),

        ),

        array(

            'name' => 'Mutual Fund Units',

            'values' => array(11.17),

        ),

        array(

            'name' => 'G-Sec, G-Sec STRIPS, SDL',

            'values' => array(7.39),

        ),

        array(

            'name' => 'Credit Exposure',

            'values' => array(6.32),

        ),

        array(

            'name' => 'Cash, Cash Equivalents and Net Current Assets',

            'values' => array(5.62),

        ),

        array(

            'name' => 'Units issued by ReIT',

            'values' => array(2.23),

        ),

        array(

            'name' => 'Units issued by InvIT',

            'values' => array(0.10),

        ),

    ),

);

Posted by admin  · 11-12-2024 - 11:20

Hello,

MS Word doesn't allow adding data tables to some chart types (pie, doughnut...). Only specific chart types such as bar or line support data tables.

You can use the legendPos option (https://www.phpdocx.com/api-documentation/word-content/add-chart-Word-document-with-PHP) to set the legend position (bottom, top, left, right...). There's no option in phpdocx to move value positions (MS Word supports this by moving manually the values, but it doesn't include a specific option).
If you want to display the data values in the legend of the doughnut chart, we recommend you add them in the legend values (as part of the text string).

Regards.