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

相关内容

热门资讯

玩家必备教程!微扑克ai机器人... 玩家必备教程!微扑克ai机器人,aapoker有外挂,扑克教程(最初存在有挂);玩家必备教程!微扑克...
科技通报!德州线上扑克辅助工具... 科技通报!德州线上扑克辅助工具app,aapoker俱乐部,2025新版总结(确实真的是有挂)aap...
了解一款!wpk胜率跟号有关么... 了解一款!wpk胜率跟号有关么,微扑克有辅助挂,wpk教程(本来是有挂)1、超多福利:超高返利,海量...
一分钟揭秘!微扑克有辅助软件吗... 一分钟揭秘!微扑克有辅助软件吗,aapoker挂,我来教教你(固有有挂)1、aapoker挂ai辅助...
重大发现!wpk德州辅助,we... 重大发现!wpk德州辅助,wepoke有挂,微扑克教程(原本有挂)1.wepoke有挂 ai辅助创建...
总算明白!微扑克辅助器是真的么... 总算明白!微扑克辅助器是真的么,德州ai辅助有用,力荐教程(都是是真的有挂)1、构建自己的微扑克辅助...
玩家必备科技!gg扑克辅助,w... 玩家必备科技!gg扑克辅助,wepoke辅助有挂,AI教程(确实真的是有挂)1、在wepoke辅助有...
重大来袭!cloudpoker... 重大来袭!cloudpoker辅助器,wepoke真的有挂,力荐教程(固有真的有挂)1、wepoke...
最新技巧!wepoke透明真的... 最新技巧!wepoke透明真的吗,智星德州菠萝有挂吗,AI教程(最初有挂);人气非常高,ai更新快且...
一分钟快速了解!德州微扑克辅助... 一分钟快速了解!德州微扑克辅助,德州微扑克辅助,高科技教程(好像存在有挂)是一款可以让一直输的玩家,...