我想为我正在开发的PM工具创建一个图表(风险矩阵,PowerPoint中的风险瀑布)。
在瀑布中,我在Y轴上创建了旋转标签。但这些标签对代码中的厚度变化没有反应。矩形看起来很奇怪,并且厚度不均匀,而是有奇怪的边缘。
如何将厚度与第一张图(左侧)的厚度相匹配?
风险瀑布标签测量
/*
-+- -+- -+- -+-
| | | |
| 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);
}
答案 0 :(得分:0)
通过在文本框上方绘制另一个矩形(没有边框)来解决问题。
struct xxx_foo2 *