Forum


Replies: 1   Views: 2407
How to prevent rounding values in bar graphs
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 dev@ram  · 19-09-2017 - 12:31

When I'm creating a bar chart with a single decimal place after 0, and using showValue = true. The ones with any non-zero decimal part is displayed but the other ones get rounded to a whole number.

E.g if the value is 7.1 , its displayed as 7.1

but if it's 7.0 it gets displayed as 7 (not 7.0 as we desired. How do I get to display with the decimal part in such cases?)

The sample data is . Here wave 2 displays 7 (we want to display it as 7.0). Is there a way to achieve this in phpdocx?

Array
        (
            [data] => Array
                (
                    [Wave 1] => Array
                        (
                            [0] => 6.9
                        )

                    [Wave 2] => Array
                        (
                            [0] => 7.0
                        )

                    [Wave 3] => Array
                        (
                            [0] => 8.1
                        )

                    [legend] => Hidden
                )

            [type] => barChart
            [color] => 12
            [title] => Delivery
            [sizeX] => 17
            [legendPos] => none
            [border] => 1
            [vgrid] => 0
            [hgrid] => 1
            [scalingMin] => 0.0
            [scalingMax] => 10
            [majorUnit] => 1
            [minorUnit] => 0
            [showValue] => 1
            [chartAlign] => left
            [showTable] => 
            [font] => Arial
            [groupBar] => clustered
        )

 

Posted by admin  · 20-09-2017 - 06:56

Hello,

The behaviour of phpdocx is the same than the default settings of MS Word. If you generate a DOCX with a chart, then you open the DOCX with MS Word and edit the data doing right click on the chart, if you change a value adding ',0' MS Word removes it automatically.

Changing the format code needs a new attribute that is not supported by the current version of phpdocx (formatCode attribute). We move the request to the dev team to add this feature to a next version of phpdocx.

Regards.