简体   繁体   English

如何在phpspreadsheet图表中设置数据标签的位置

[英]How to set position of Data Labels in phpspreadsheet chart

I want to generate chart using phpspreadsheet library.我想使用 phpspreadsheet 库生成图表。 Below is my requirement that I am not able to fulfill right now using phpspreadsheet.以下是我现在无法使用 phpspreadsheet 满足的要求。

please check below images and suggest me options for below points.请检查下面的图片并建议我以下几点的选项。

  1. Want to set position of Data Values to "Below" of points.想要将数据值的位置设置为点的“下方”。
  2. Want to remove border from Y-Axis same as Required Output Image.想要从 Y 轴上删除边框,与所需的输出图像相同。
  3. Want to set Line above X-Axis Labels (6/17,7/17) same as Required Image style.想要将 X 轴标签(6/17、7/17)上方的线设置为与所需图像样式相同。

How can I do that.我怎样才能做到这一点。 I have searched whole Chart.php writer file but not found any usefull function.我搜索了整个 Chart.php 编写器文件,但没有找到任何有用的功能。

Help me guys if possible or any other alternate Library also there...如果可能,请帮助我,或者那里还有其他任何替代图书馆...

Current Output:电流输出:

这是我现在得到的。

Required Output :所需输出: 我想要这样

Thanks in Advance.提前致谢。

I have searched lot off and finally got idea, That Chart is XML code and loaded in Excel.我已经搜索了很多,终于有了想法,该图表是 XML 代码并加载到 Excel 中。 So phpspreadsheet is already doing same for chart, phpspreadsheet itself generates xml code.所以 phpspreadsheet 已经对图表做了同样的事情,phpspreadsheet 本身生成了 xml 代码。

$objWriter->startElement('c:dLblPos');
$showVal = (empty($chartLayout)) ? 0 : $chartLayout->getShowVal();
$objWriter->writeAttribute('val', 't');
$objWriter->endElement();

We just need to add this lines in Phpspreadsheet/Writer/Xlsx/Chart.php on Line No : 361我们只需要在第 361 行的 Phpspreadsheet/Writer/Xlsx/Chart.php 中添加这一行

Here You can set position of label for values.您可以在此处设置值的标签位置。

"t" : Top "t" : 顶部

"b" : Below "b" : 下面

Thanks谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM