Search code examples
phpopentbs

OpenTBS / PHP - How do I dynamically generate horizontal values for embedded graph inside of docx template?


I have a graph for which I was able to manually create x axis values in a docx template. The template outputs the correct graph. Instead of relying upon manually entering all x values and substituting the values from the php array, I want to dynamically populate the horizontal axis with values from a php array.

PHP Code

// --------------------------------------------
        // Merging and other operations on the template
        // --------------------------------------------
        // Change chart series
        $ChartNameOrNum = 'Buildup'; // Title of the shape that embeds the chart
        $SeriesNameOrNum = 'Series 1';
        $NewValues = array($buildupLabels['TotalActionItems'], $buildupSeries['TotalActionItems'] );
        $NewLegend = "Total Action Items";
        $TBS->PlugIn(OPENTBS_CHART, $ChartNameOrNum, $SeriesNameOrNum, $NewValues, $NewLegend);

        // Delete comments
        $TBS->PlugIn(OPENTBS_DELETE_COMMENTS);

Output File with Rendered Chart

Output Chart

Chart Template

BuildUp Template

Table of x-axis values

Manually Entered Values

How can I achieve the above? Is this possible using the OpenTBS, or do I need to manually enter all x axis values?


Solution

  • I just discovered that I do not need to automatically generate all of the horizontal values in the embedded chart. All I need to do is put one date in the first record (e.g. Mar 05 15 or anything else not even in the range of dates I am populating) and the series will automatically populate all available dates from my PHP array.