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

相关内容

热门资讯

黑科技新版(aapoker)外... 黑科技新版(aapoker)外挂辅助挂(透视)德州教程(果然存在有挂);1、游戏颠覆性的策略玩法,独...
黑科技最新!(wEPoke)软... 黑科技最新!(wEPoke)软件透明挂,(Wepoke)素来真的是有挂,wepoke教程(有挂技巧)...
黑科技游戏!(poker)外挂... 黑科技游戏!(poker)外挂辅助软件,(pokerrrr2)一向是真的有挂,AI教程(有挂技巧);...
黑科技美元局(微扑克ai)外挂... 黑科技美元局(微扑克ai)外挂透视辅助下载(透视)细节揭秘(一贯是真的有挂)小薇(透视辅助)致您一封...
黑科技脚本!(德扑)外挂辅助插... 黑科技脚本!(德扑)外挂辅助插件,(德扑之星)一贯真的有挂,德州教程(有挂辅助);亲真的是有正版授权...
黑科技了解(wePoKe)黑科... 黑科技了解(wePoKe)黑科技透明挂辅助方法(透视)解密教程(一贯是有挂)该软件可以轻松地帮助玩家...
黑科技安装(wepower)黑... 黑科技安装(wepower)黑科技透明挂辅助教程(透视)力荐教程(好像真的是有挂);1、首先打开we...
黑科技科技!(wePokE)软... 黑科技科技!(wePokE)软件透明挂,(WepOke)素来真的有挂,攻略方法(有挂教程)1、不需要...
黑科技了解(德州之星)外挂辅助... 黑科技了解(德州之星)外挂辅助助手(透视)黑科技教程(切实真的是有挂)1、下载好德州之星辅助软件之后...
黑科技总结!(WPK)透视辅助... 黑科技总结!(WPK)透视辅助app,(WPK)最初真的有挂,科技教程(有挂教程);玩家必备必赢加哟...