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数据标签的格式控制。

相关内容

热门资讯

透视苹果版!wpk辅助器,aa... 透视苹果版!wpk辅助器,aapkoer德州辅助挂下载,分享一款(有挂技巧);透视苹果版!wpk辅助...
透视透视!aapoker辅助工... 透视透视!aapoker辅助工具存在吗,aapoker辅助包,盘点一款(有挂教程)1、点击下载安装,...
透视透视挂!aapoker辅助... 透视透视挂!aapoker辅助插件工具下载,红龙poker辅助,热点讨论(有挂详情);进入游戏-大厅...
透视黑科技!德普之星有没有挂,... 透视黑科技!德普之星有没有挂,wpk透视脚本,科技新动态(有挂技巧)1、这是跨平台的黑科技,在线的操...
透视总结!wepoker透视,... 透视总结!wepoker透视,wpk脚本辅助器,让我来分享经验(有挂辅助挂)1、玩家可以在软件透明挂...
透视了解!德普之星透视辅助软件... 透视了解!德普之星透视辅助软件是真的吗,德普之星有没有挂,每日必备(有挂了解);1、下载好辅助软件之...
透视神器!wpk辅助软件,we... 透视神器!wpk辅助软件,wepoker辅助器下载,带你了解(有挂攻略);1、用户打开应用后不用登录...
透视软件!hhpoker透视功... 透视软件!hhpoker透视功能如何下载,德普之星透视辅助ios,玩家必看秘籍(有挂透明);1、系统...
透视系统!aapoker透视插... 透视系统!aapoker透视插件,wepoker免费永久脚本,盘点几款(有挂教程);1、透视辅助简单...
透视透视!hhpoker辅助下... 透视透视!hhpoker辅助下载,德普之星透视辅助软件是真的吗,一分钟教你(有挂透明)1、打开软件启...