Arbeta med diagram - Aspose.Slides FOSS för Python

Aspose.Slides FOSS for Python provides classes for working with working with charts.


Overview

De viktigaste klasserna är:

  • Chart
  • ChartSeries
  • ChartSeriesCollection
  • ChartSeriesGroup
  • ChartSeriesGroupCollection

Att börja

Installera Aspose.Slides FOSS för Python:

pip install aspose-slides-foss

Grundläggande användning

import aspose.slides_foss as slides
from aspose.slides_foss.charts import ChartType
from aspose.slides_foss.export import SaveFormat

with slides.Presentation() as prs:
    slide = prs.slides[0]
    chart = slide.shapes.add_chart(ChartType.CLUSTERED_COLUMN, 100, 100, 500, 400)

    # add_chart() seeds the chart with sample series/category data
    series = chart.chart_data.series[0]
    print(f"Series: {series.name.as_literal_string}, {len(series.data_points)} point(s)")

    prs.save("chart.pptx", SaveFormat.PPTX)

Tips och bästa praxis

  • Alltid avlägsna dokumentobjekt efter användning
  • Handla filer I/O undantag när du läser eller skriver filerna
  • Se till att API referens För de senaste signaturerna

API Referens sammanfattning

ClassDescription
ChartSe referensdokument
ChartSeriesSe referensdokument
ChartSeriesCollectionSe referensdokument
ChartSeriesGroupSe referensdokument
ChartSeriesGroupCollectionSe referensdokument

För fullständig information, se den API referens.

See Also

 Svenska