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

相关内容

热门资讯

十分钟了解!拱趴大菠萝怎么拿好... 十分钟了解!拱趴大菠萝怎么拿好牌,白金岛有外挂吗,系统教程(有挂总结)该软件可以轻松地帮助玩家将拱趴...
四分钟了解!浩瀚麻将十三水机器... 四分钟了解!浩瀚麻将十三水机器人,手机好友赣南麻将到底有没有挂,安装教程(有挂技巧)1、起透看视 手...
三分钟了解!中至卧龙能控制输赢... 三分钟了解!中至卧龙能控制输赢吗,中至都昌讨赏有挂吗,实用技巧(有挂规律)1、点击下载安装,中至卧龙...
四分钟了解!闲来湖南跑胡子游戏... 四分钟了解!闲来湖南跑胡子游戏攻略,财神十三张开挂,切实教程(有挂规律)1、玩家可以在闲来湖南跑胡子...
十分钟了解!蜜瓜大厅有挂吗,老... 十分钟了解!蜜瓜大厅有挂吗,老友互娱有后台吗,AI教程(有挂普及)老友互娱有后台吗软件透明挂微扑克w...
三分钟了解!蛮籽重庆麻将有挂吗... 三分钟了解!蛮籽重庆麻将有挂吗,天天十三张有外挂没,透明教程(有挂黑科技)1、上手简单,内置详细流程...
1分钟了解!聚星扑克德州有假吗... 1分钟了解!聚星扑克德州有假吗,中至麻将打炸有挂的吗,曝光教程(有挂解说)小薇(透视辅助)致您一封信...
9分钟了解!乐乐上海斗地主有挂... 9分钟了解!乐乐上海斗地主有挂吗,边锋干瞪眼外挂效果,2025教程(有挂解说);1、乐乐上海斗地主有...
4分钟了解!雀魂外 挂,天天仙... 4分钟了解!雀魂外 挂,天天仙桃麻将有挂,科技教程(有挂黑科技)4分钟了解!雀魂外 挂,天天仙桃麻将...
6分钟了解!微信小程序途游辅助... 6分钟了解!微信小程序途游辅助器,心悦填大坑能控制发牌么,必赢方法(有挂透明)1、进入到心悦填大坑能...