แผนภูมิในงานนำเสนอ PowerPoint

แผนภูมิให้กลไกที่รวดเร็วและกระชับในการนำเสนอข้อมูลเชิงสถิติ มันช่วยให้ผู้มีส่วนได้ส่วนเสียที่เกี่ยวข้องสามารถตัดสินใจที่สำคัญได้อย่างรวดเร็ว แผนภูมิประกอบด้วยข้อมูลและหมวดหมู่ที่เกี่ยวข้อง ดังนั้นการดำเนินการเช่นการเพิ่ม การอัปเดต และการลบข้อมูลแผนภูมิใน PowerPoint หมวดหมู่ที่เกี่ยวข้องสามารถทำได้โดยใช้ Aspose.Slides Cloud API

นอกจากนี้ เพื่อที่จะใช้ SDK คุณต้องติดตั้งมันและวิธีที่ง่ายที่สุดคือผ่านห้องสมุด NuGet ดังนั้นโปรดลองใช้คำสั่งต่อไปนี้ในคอนโซล Package Manager

 Install-Package Aspose.Slides-Cloud -Version 21.2.0

Cloud API ยังสามารถเข้าถึงได้โดยใช้คำสั่ง cURL ผ่านเทอร์มินัล ดังนั้นเพื่อที่จะเข้าถึงมัน คุณต้องจัดเตรียมโทเค็น JWT ซึ่งถูกสร้างจาก Client ID และ Client Secret ของคุณ ดังนั้นเราขอแนะนำให้คุณเยี่ยมชมลิงก์ต่อไปนี้เพื่อทำความเข้าใจเพิ่มเติมเกี่ยวกับ

การทำงานกับหมวดหมู่ของแผนภูมิ

แหล่งข้อมูลใหม่เป็นแหล่งข้อมูลย่อยของรูปร่าง มันทำงานเฉพาะสำหรับรูปร่างของแผนภูมิที่รองรับหมวดหมู่ (เสา, เส้น, ฯลฯ) มันอนุญาตให้เราเพิ่ม, แก้ไข & ลบหมวดหมู่แผนภูมิพร้อมกับจุดข้อมูลที่เกี่ยวข้อง บทความนี้มุ่งเน้นไปที่หัวข้อต่อไปนี้

เพิ่มหมวดหมู่ลงในแผนภูมิ

Request URL

<code>POST https://api.aspose.cloud/v3.0/slides/myPresentaion.pptx/slides/1/shapes/1/categories?folder=myFolder</code>

C#.NET

string MyAppKey = "xxxxxxxx";    // Get AppKey and AppSID from https://dashboard.aspose.cloud/
string MyAppSid = "xxxxxxxx";    // Get AppKey and AppSID from https://dashboard.aspose.cloud/

SlidesApi api = new SlidesApi(MyAppSid, MyAppKey);
ChartCategory dto = new ChartCategory
{
    Value = "NewCategory",
    DataPoints = new List<OneValueChartDataPoint>
    {
        new OneValueChartDataPoint { Value = 5.5 },
        new OneValueChartDataPoint { Value = 76 },
        new OneValueChartDataPoint { Value = 27 }
    }
};
PostChartCategoryRequest request = new PostChartCategoryRequest
{
    Name = "myPresentaion.pptx",
    Folder = "myFolder",
    SlideIndex = 1,
    ShapeIndex = 1,
    Category = dto
};
Chart chart = api.PostChartCategory(request);
Console.WriteLine(chart.Categories.Count);

อัปเดตหมวดหมู่แผนภูมิ

Request URL

<code>PUT https://api.aspose.cloud/v3.0/slides/myPresentaion.pptx/slides/1/shapes/1/categories/2?folder=myFolder</code>

C#.NET

string MyAppKey = "xxxxxxxx";    // Get AppKey and AppSID from https://dashboard.aspose.cloud/
string MyAppSid = "xxxxxxxx";    // Get AppKey and AppSID from https://dashboard.aspose.cloud/

SlidesApi api = new SlidesApi(MyAppSid, MyAppKey);
ChartCategory dto = new ChartCategory
{
    Value = "UpdatedCategory",
    DataPoints = new List<OneValueChartDataPoint>
    {
        new OneValueChartDataPoint { Value = 5.5 },
        new OneValueChartDataPoint { Value = 76 },
        new OneValueChartDataPoint { Value = 27 }
    }
};
PutChartCategoryRequest request = new PutChartCategoryRequest
{
    Name = "myPresentaion.pptx",
    Folder = "myFolder",
    SlideIndex = 1,
    ShapeIndex = 1,
    CategoryIndex = 2,
    Category = dto
};
Chart chart = api.PutChartCategory(request);
Console.WriteLine(chart.Categories.Count);

ลบหมวดหมู่แผนภูมิ

API Aspose.Slides Cloud ยังเสนอความสามารถในการลบหมวดหมู่ใด ๆ ในวัตถุแผนภูมิที่มีอยู่ คุณเพียงแค่ต้องระบุดัชนีของสไลด์ ดัชนีรูปทรงที่เกี่ยวข้อง และรหัสหมวดหมู่ที่เกี่ยวข้องเพื่อให้ตรงตามความต้องการ

Request URL

<code>DELETE https://api.aspose.cloud/v3.0/slides/myPresentaion.pptx/slides/1/shapes/1/categories/2?folder=myFolder</code>

C#.NET

string MyAppKey = "xxxxxxxx";    // Get AppKey and AppSID from https://dashboard.aspose.cloud/
string MyAppSid = "xxxxxxxx";    // Get AppKey and AppSID from https://dashboard.aspose.cloud/

SlidesApi api = new SlidesApi(MyAppSid, MyAppKey);
DeleteChartCategoryRequest request = new DeleteChartCategoryRequest
{
    Name = "myPresentaion.pptx",
    Folder = "myFolder",
    SlideIndex = 1,
    ShapeIndex = 1,
    CategoryIndex = 2
};
Chart chart = api.DeleteChartCategory(request);
Console.WriteLine(chart.Categories.Count);

การทำงานกับข้อมูลแผนภูมิ

API สามารถให้ฟีเจอร์ในการจัดการจุดข้อมูลที่เกี่ยวข้องกับวัตถุแผนภูมิภายในสไลด์ PowerPoint ได้อย่างเต็มที่ ตามการอัปเดตล่าสุดใน API แหล่งข้อมูลใหม่เป็นแหล่งข้อมูลย่อยของ series มันทำงานเฉพาะสำหรับรูปทรง Chart และอนุญาตให้เราเพิ่ม แก้ไข และลบจุดข้อมูลแต่ละจุด

เพิ่มจุดข้อมูลไปยังชุดข้อมูลในแผนภูมิ

นี่ทำงานร่วมกับชุดข้อมูลแบบกระจายและฟองอากาศ คุณไม่สามารถสร้างจุดข้อมูลสำหรับชุดข้อมูลที่มีค่าเดียวโดยไม่สร้างหมวดหมู่ที่เกี่ยวข้อง

Request URL

<code>POST https://api.aspose.cloud/v3.0/slides/myPresentaion.pptx/slides/1/shapes/1/series/2/dataPoints?folder=myFolder</code>

C#.NET

string MyAppKey = "xxxxxxxx";    // Get AppKey and AppSID from https://dashboard.aspose.cloud/
string MyAppSid = "xxxxxxxx";    // Get AppKey and AppSID from https://dashboard.aspose.cloud/

SlidesApi api = new SlidesApi(MyAppSid, MyAppKey);
ScatterChartDataPoint dto = new ScatterChartDataPoint
{
 XValue = 5.5,
 YValue = 8
};
PostChartDataPointRequest request = new PostChartDataPointRequest
{
 Name = "myPresentaion.pptx",
 Folder = "myFolder",
 SlideIndex = 1,
 ShapeIndex = 1,
 SeriesIndex = 2,
 DataPoint = dto
};
Chart chart = api.PostChartDataPoint(request);
Console.WriteLine(((ScatterSeries)chart.Series[1]).DataPoints.Count);

อัปเดตจุดข้อมูลแผนภูมิ

คุณยังสามารถใช้ API เพื่ออัปเดตจุดข้อมูลในแผนภูมิที่มีอยู่ได้

Request URL

<code>PUT https://api.aspose.cloud/v3.0/slides/myPresentaion.pptx/slides/1/shapes/1/series/2/dataPoints/2?folder=myFolder</code>

C#.NET

string MyAppKey = "xxxxxxxx";    // Get AppKey and AppSID from https://dashboard.aspose.cloud/
string MyAppSid = "xxxxxxxx";    // Get AppKey and AppSID from https://dashboard.aspose.cloud/

SlidesApi api = new SlidesApi(MyAppSid, MyAppKey);

ScatterChartDataPoint dto = new ScatterChartDataPoint
{
 XValue = 5.5,
 YValue = 8
};
PutChartDataPointRequest request = new PutChartDataPointRequest
{
 Name = "myPresentaion.pptx",
 Folder = "myFolder",
 SlideIndex = 1,
 ShapeIndex = 1,
 SeriesIndex = 2,
 PointIndex = 2,
 DataPoint = dto
};
Chart chart = api.PutChartDataPoint(request);
Console.WriteLine(((ScatterSeries)chart.Series[1]).DataPoints[1].XValue); //5.5

ลบจุดข้อมูลแผนภูมิ

สำหรับข้อมูลทุกจุดที่มีอยู่ภายในอ็อบเจ็กต์ Chart API ยังช่วยให้คุณสามารถลบจุดใด ๆ ได้โดยการให้ค่าสำหรับ PointIndex.

Request URL

<code>DELETE https://api.aspose.cloud/v3.0/slides/myPresentaion.pptx/slides/1/shapes/1/series/2/dataPoints/2?folder=myFolder</code>

C#.NET

string MyAppKey = "xxxxxxxx";    // Get AppKey and AppSID from https://dashboard.aspose.cloud/
string MyAppSid = "xxxxxxxx";    // Get AppKey and AppSID from https://dashboard.aspose.cloud/

SlidesApi api = new SlidesApi(MyAppSid, MyAppKey);
DeleteChartDataPointRequest request = new DeleteChartDataPointRequest
{
 Name = "myPresentaion.pptx",
 Folder = "myFolder",
 SlideIndex = 1,
 ShapeIndex = 1,
 SeriesIndex = 2,
 PointIndex = 2
};
Chart chart = api.DeleteChartDataPoint(request);
Console.WriteLine(((ScatterSeries)chart.Series[1]).DataPoints.Count);