Forum


Replies: 1   Views: 2871
Non-smooth linechart
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  · 23-02-2017 - 11:42

Hello,

The smooth option is only available for scatter charts, you can read about this option on:

http://www.phpdocx.com/api-documentation/word-content/add-chart-Word-document-with-PHP

Anyway, you can add support for line charts easily:

1. Edit the file CreateLineChart.inc and around line 169 add these lines:

            if (!empty($this->_smooth) && $this->_smooth && $this->_symbol != 'dot') {
                $this->generateSMOOTH();
            }

Instead of this code:

            foreach ($this->values as $legend => $value) {
                if ($legend == 'legend') {
                    continue;
                }
                $this->generatePT($num);
                $this->generateV($value[$i]);
                $num++;
            }

            $this->cleanTemplate3();

 

The class must use this code:

            foreach ($this->values as $legend => $value) {
                if ($legend == 'legend') {
                    continue;
                }
                $this->generatePT($num);
                $this->generateV($value[$i]);
                $num++;
            }

            if (!empty($this->_smooth) && $this->_smooth && $this->_symbol != 'dot') {
                $this->generateSMOOTH();
            }
            $this->cleanTemplate3();

2. Use the new option (smooth option) when adding the chart:

$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',
    'smooth' => true,
);
$docx->addChart($paramsChart);

Regards.