1

我正在尝试创建一个堆叠条形图,如下所示嵌入在 PowerPoint 模板的幻灯片上。当我在下面运行我的脚本时,我收到了一个错误。

TinyButStrong 错误 OpenTBS 插件:(ChartChangeSeries)'chart3':无法在图表'chart3'中找到系列'Series 3'。该过程正在结束,除非您将 NoErr 属性设置为 true。

据我所见,我的系列与 x 轴的两个标签中的每一个都明确定义。

我哪里出错了,我该如何解决这个错误?

模板中的表定义

堆积条形图示例图像

$ecdClosureStatus = getClosureChartData('ECD');
    $ChartNameOrNum = 'chart3'; // Title of the shape that embeds the chart
    $ChartRef = 'chart3'; // Title of the shape that embeds the chart
    $SeriesNameOrNum = 'Series 1';
    $NewLegend = "Closed On Time";
    $NewValues =    array(


(int)$ecdClosureStatus['ClosedOnTime'],
                                    0
                                );
$TBS->PlugIn(OPENTBS_CHART, $ChartNameOrNum, $SeriesNameOrNum, $NewValues, $NewLegend);

$SeriesNameOrNum = 'Series 2';
$NewLegend =    'Closed 1-30 Days Late';
$NewValues =    array(
                                    0,
                                    (int)$ecdClosureStatus['OneToThirtyDaysLate']
                                );
$TBS->PlugIn(OPENTBS_CHART, $ChartNameOrNum, $SeriesNameOrNum, $NewValues, $NewLegend);

$SeriesNameOrNum = 'Series 3';
$NewLegend =        'Closed 31-60 Days Late';
$NewValues =    array(
                                    0,
                                    (int)$ecdClosureStatus['ThirtyOneToSixtyDaysLate']
                                );
$TBS->PlugIn(OPENTBS_CHART, $ChartNameOrNum, $SeriesNameOrNum, $NewValues, $NewLegend);

$SeriesNameOrNum = 'Series 4';
$NewLegend =    'Closed 61-90 Days Late';
$NewValues =        array(
                                    0,
                                    (int)$ecdClosureStatus['SixtyOneToNinetyDaysLate']
                                );
$TBS->PlugIn(OPENTBS_CHART, $ChartNameOrNum, $SeriesNameOrNum, $NewValues, $NewLegend);

$SeriesNameOrNum = 'Series 5';
$NewLegend = 'Closed >90 Days Late';
$NewValues =    array(
                                    0,
                                    (int)$ecdClosureStatus['ClosedMoreThanNinetyDaysLate']
                                );
$TBS->PlugIn(OPENTBS_CHART, $ChartNameOrNum, $SeriesNameOrNum, $NewValues, $NewLegend);
4

2 回答 2

2

您的代码似乎没问题。问题可能来自系列#3,它可能没有像您期望的那样在内部命名。在电子表格查看器中仔细检查名称,最后不能有空格。您也可以尝试使用“在 Excel 女士中修改数据”按钮。

不过,您可以使用返回图表数据的新 OpenTBS 命令。它在OpenTBS beta 版本 1.9.5中可用,但它是稳定的。

命令:

$data = $TBS->PlugIn(OPENTBS_CHART_INFO, 'chart3');   
var_dump($data);
于 2016-01-14T17:40:52.000 回答
0

我将每个系列的 $NewValues 数组修改为包含两个元素的数组,第一个元素是 x 轴值,第二个元素是 y 轴值。x 轴值是两个值的数组(“准时关门”、“晚关门”),y 轴是两个元素的数组(一个元素为零,另一个是该 x 值的值(准时关门或迟关门)

输出图

输出堆积条形图

例子

 $NewValues =   array(array('Closed On Time', 'Closed Late'), array(
                                        (int)$ecdClosureStatus['ClosedOnTime'],
                                        0
                                    ));

解决方案代码

$ecdClosureStatus = getClosureChartData('ECD');
    $ChartNameOrNum = 'chart3'; // Title of the shape that embeds the chart
    $ChartRef = 'chart3'; // Title of the shape that embeds the chart
    $SeriesNameOrNum = 'Series 1';
    $NewLegend = "Closed On Time";
    $NewValues =    array(array('Closed On Time', 'Closed Late'), array(
                                        (int)$ecdClosureStatus['ClosedOnTime'],
                                        0
                                    ));
    $TBS->PlugIn(OPENTBS_CHART, $ChartNameOrNum, $SeriesNameOrNum, $NewValues, $NewLegend);

    $SeriesNameOrNum = 'Series 2';
    $NewLegend =    '1-30 Days Late';
    $NewValues =        array(array('Closed On Time', 'Closed Late'), array(
                                        0,
                                        (int)$ecdClosureStatus['OneToThirtyDaysLate']
                                    ));
    $TBS->PlugIn(OPENTBS_CHART, $ChartNameOrNum, $SeriesNameOrNum, $NewValues, $NewLegend);

    $SeriesNameOrNum = 'Series 3';
    $NewLegend =        ' 31-60 Days Late';
    $NewValues =        array(array('Closed On Time', 'Closed Late'), array(
                                        0,
                                        (int)$ecdClosureStatus['ThirtyOneToSixtyDaysLate']
                                    ));
    $TBS->PlugIn(OPENTBS_CHART, $ChartNameOrNum, $SeriesNameOrNum, $NewValues, $NewLegend);

    $SeriesNameOrNum = 'Series 4';
    $NewLegend =    '61-90 Days Late';
    $NewValues =            array(array('Closed On Time', 'Closed Late'), array(
                                        0,
                                        (int)$ecdClosureStatus['SixtyOneToNinetyDaysLate']
                                    ));
    $TBS->PlugIn(OPENTBS_CHART, $ChartNameOrNum, $SeriesNameOrNum, $NewValues, $NewLegend);

    $SeriesNameOrNum = 'Series 5';
    $NewLegend = ' >90 Days Late';
    $NewValues =        array(array('Closed On Time', 'Closed Late'), array(
                                        0,
                                        (int)$ecdClosureStatus['MoreThanNinetyDaysLate']
                                    ));
    $TBS->PlugIn(OPENTBS_CHART, $ChartNameOrNum, $SeriesNameOrNum, $NewValues, $NewLegend);
于 2016-01-14T18:31:12.447 回答