AsposeslidesPythonlinechartlabelformatting
创始人
2024-09-20 11:30:07
0

使用Aspose.Slides for Python API,通过获取LineChart数据点对应的Series对象,再获取SeriesDataPoint,最后设置LabelFormat属性实现数据标签格式控制。以下是示例代码:

from asposeslides import Presentation
from asposeslides.charts import ChartType
from asposeslides.charts import LineChart
from asposeslides.charts import ChartDataPointType
from asposeslides.charts import ChartDataPoint
from asposeslides.charts import ChartSeries
from asposeslides.charts import LabelFormat

# 加载演示文稿
pres = Presentation("presentation.pptx")
# 获取第一个幻灯片
slide = pres.slides[0]
# 插入一个空白的折线图
chart_type = ChartType.Line
chart = slide.shapes.add_chart(chart_type, 0, 0, 500, 300, True)
line_chart = chart.chart_data.chart
# 添加一个数据系列
series = line_chart.series.add("销售额")
# 添加数据点
data_points = series.data_points
data_points.add_data_point(ChartDataPointType.DataPointNumeric, 50)
data_points.add_data_point(ChartDataPointType.DataPointNumeric, 30)
data_points.add_data_point(ChartDataPointType.DataPointNumeric, 70)
data_points.add_data_point(ChartDataPointType.DataPointNumeric, 40)
data_points.add_data_point(ChartDataPointType.DataPointNumeric, 60)
# 获取每个数据点对象
for point in data_points:
    # 获取每个数据点对应的Series对象
    series = point.series
    # 获取SeriesDataPoint对象
    data_point = series.data_points[point.index]
    # 设置数据标签格式控制
    label_format = data_point.label.format
    label_format.text_format.portion_format.font_height = 12 # 字体大小
    label_format.number_format = "$#.00" # 数字格式

# 保存演示文稿
pres.save("presentation.pptx")

其中,通过访问LineChart对象上的Series对象,再获取SeriesDataPoint对象,最后通过设置LabelFormat属性,实现LineChart数据标签的格式控制。

相关内容

热门资讯

透视安卓版!wepoker辅助... 透视安卓版!wepoker辅助下载,werplan外卦神器,可靠教程(素来存在有挂);科技安装教程;...
透视存在!wepoker透视脚... 透视存在!wepoker透视脚本免费下载,pokeplus脚本,我来教教你(原来存在有挂);wepo...
透视讲解!wepoker作弊辅... 透视讲解!wepoker作弊辅助,aapoker透视脚本,透明挂教程(果然真的有挂);亲,其实确实真...
辅助透视!德普之星有没有挂,w... 辅助透视!德普之星有没有挂,wepoker透视脚本苹果版,2025新版总结(果然是真的有挂)科技教程...
透视软件!wpk透视表,约局吧... 透视软件!wpk透视表,约局吧开挂神器是真的吗,曝光教程(都是存在有挂);人气非常高,ai更新快且高...
透视挂透视!智星德州菠萝透视插... 透视挂透视!智星德州菠萝透视插件工具,德普辅助器辅助器怎么用,德州论坛(本然是真的有挂);大神普及一...
透视系统!aapoker辅助插... 透视系统!aapoker辅助插件工具,aapoker透视脚本,力荐教程(果然是真的有挂);原来确实真...
透视攻略!hhpoker透视方... 透视攻略!hhpoker透视方法,aapoker免费透视脚本,透明挂教程(真是有挂);最新版2024...
透视数据!aapoker可以开... 透视数据!aapoker可以开挂吗,wepoker透视脚本是什么,普及教程(从前有挂);《WPK辅助...
透视辅助!aapoker辅助插... 1、透视辅助!aapoker辅助插件工具,德普之星辅助软件,可靠教程(原先真的是有挂);详细教程。2...