OpenTBS / PHP - 如何在docx模板内部动态生成嵌入图的水平值?

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?

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.

OpenTBS enables you to change x and y values for any of the series. So you just have to change all (x,y) items for all of your series then old x values should totally disappear in your chart. You have to get an automatic min and max for the x axis in order to have it adapted to the new values.

You also have to keep in mind the Ms Office Charts behavior :

  • If your chart type is a XY (also named Scatter), then (x,y) of your series entries can be in any order, and the x axis will not necessary display values used by items. This is nice when you have several series with different x values and you want to display unused x values in the x axe.
  • If your chart type different from a XY then x values are considered as categories. Only used values will be displayed in the x axis. If tow series have different categories all possible values are displayed in the x axis.