如何在 PHPPowerPoint 中增加矩形边框的厚度?

How to increase thickness of border for a rectangle in PHPPowerPoint?

我想为我正在开发的 PM 工具创建图表(风险矩阵,PowerPoint 中的风险瀑布图)。

在我在 Y 轴上创建的瀑布中,旋转了标签。但是这些标签不响应代码中的厚度变化。矩形看起来很奇怪,厚度不均匀,边缘很奇怪。

如何使厚度与第一张图(左侧)的厚度匹配?

示例 PowerPoint 导出图形

风险瀑布标签测量

/*                           
                           -+-    -+-             -+- -+-    
                            |      |               |   |
                            |  offsetRiskY (High)  |   |
                            |      |               |   |
                         ---+---  -+-              |   offsetRiskY(Med) = offsetRiskY(High) + heightRiskHigh
                            |      |               |   |           
      centerRiskY --------- + heightRisk (High)    |   |                                                                   
                            |      |               |   |                                                                  
                         ---+---  -+-              |  -+-                                                                
                            |      |               |                                                                       
      centerRiskY --------- + heightRisk (Med)     offsetRiskYLow = offsetRiskYHigh + heightRiskHigh + heightRiskMed   +   waterfallHeight = heightHigh + heightMed + heightLow                 
                            |      |               |                                                                      
                         ---+---  -+-             -+-                                                                    
                            |      |                                                                                      
      centerRiskY --------- + heightRisk (Low)                                                                            
                            |      |                                                                                       
                         ---+---  -+-                                                                                    
                          * 
                         / \
                          |
                          |
                          |
                          |
    halfLabelWidth  ------+

                            |------heightRisk/2-----+------heightRisk/2------|
                            +------------------------------------------------+
         halfLabelWidth     |                                                |
                            +                   Risk Label                   + 
         halfLabelWidth     |                                                |
                            +------------------------------------------------+

*/

代码

public function generateRiskWaterfallLabelYAxis($heightRisk, $offsetRiskY, $labelText)
{
    $halfRiskHeight = $heightRisk/2;
    $centerRiskY = $offsetRiskY + $halfRiskHeight;
    $labelWidth = self::$waterfallHeight - $centerRiskY;
    $halfLabelWidth = self::$waterfallLabelWidth/2;
    $currentSlide = $this->riskPPT->getActiveSlide();
    $shape = $currentSlide->createRichTextShape()->setHeight($halfLabelWidth)->setWidth($heightRisk);    //swap width, height for rotation (90 degrees)
    $shape->setOffsetX(-$halfRiskHeight);
    $shape->setOffsetY($centerRiskY + self::$offsetWaterfallY);
    $shape->setRotation(-90);
    $offsetX = $shape->getOffsetX() + self::$offsetWaterfallX - $halfLabelWidth/2;
    $offsetY = $shape->getOffsetY() - $halfLabelWidth/2;
    $shape->setOffsetX($offsetX);
    $shape->setOffsetY($offsetY);
    $textRun = $shape->createTextRun($labelText);    $shape->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER);    $shape->getActiveParagraph()->getAlignment()->setVertical(Alignment::VERTICAL_CENTER);    
    $shape->getBorder()->setColor(new Color('FF'. self::$borderColor))->setLineStyle(Border::LINE_SINGLE)->setLineWidth(1);
}

public function generateRiskWaterfallLabelsYAxis()
{                    
    $maxRisk = 1.0;
    //High
    $heightHigh = self::$waterfallHeight*($maxRisk-$this->minHigh);
    $offsetRiskHigh = 0;
    $riskTextHigh = 'High';
    $this->generateRiskWaterfallLabelYAxis($heightHigh, $offsetRiskHigh, $riskTextHigh);

    //Med
    $heightMed = self::$waterfallHeight*($this->minHigh-$this->maxLow);
    $offsetRiskMed = $heightHigh;
    $riskTextMed = 'Med';
    $this->generateRiskWaterfallLabelYAxis($heightMed, $offsetRiskMed, $riskTextMed);

    //Low 
    $heightLow = self::$waterfallHeight*$this->maxLow;
    $offsetRiskLow = $heightHigh + $heightMed;
    $riskTextLow = 'Low';
    $this->generateRiskWaterfallLabelYAxis($heightLow, $offsetRiskLow, $riskTextLow);
}

问题已通过在文本框上方绘制另一个矩形(无边框)解决。

        $shape = $currentSlide->createRichTextShape()->setHeight($heightRisk)->setWidth($halfLabelWidth); 
        $offsetX = self::$offsetWaterfallX - $halfLabelWidth;
        $offsetY = self::$offsetWaterfallY + $offsetRiskY;
        $shape->setOffsetX($offsetX);
        $shape->setOffsetY($offsetY);
        $shape->getBorder()->setColor(new Color('FF000000'))->setLineStyle(Border::LINE_SINGLE);