مخطط دائري
خيارات المخطط الثاني لمخطط الدائرة أو مخطط الشريط الدائري
Aspose.Slides لـ C++ تدعم الآن خيارات المخطط الثاني لمخطط الدائرة أو مخطط الشريط الدائري. في هذا الموضوع، سنرى مع مثال كيفية تحديد هذه الخيارات باستخدام Aspose.Slides. لتحديد الخصائص. يرجى اتباع الخطوات أدناه:
- إنشاء كائن من فئة Presentation.
- إضافة مخطط إلى الشريحة.
- تحديد خيارات المخطط الثاني للمخطط.
- كتابة العرض التقديمي إلى القرص.
في المثال المعطى أدناه، قمنا بتعيين خصائص مختلفة لمخطط الدائرة.
For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-C | |
// The path to the documents directory. | |
const String outPath = u"../out/SecondPlotOptionsforCharts_out.pptx"; | |
//Instantiate Presentation class that represents PPTX file | |
SharedPtr<Presentation> pres = MakeObject<Presentation>(); | |
//Access first slide | |
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0); | |
// Add chart with default data | |
SharedPtr<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::Pie, 0, 0, 500, 500); | |
// Take first chart series | |
SharedPtr<IChartSeries> series = chart->get_ChartData()->get_Series()->idx_get(0); | |
// Set different properties | |
series->get_Labels()->get_DefaultDataLabelFormat()->set_ShowValue(true); | |
series->get_ParentSeriesGroup()->set_SecondPieSize ( 149); | |
series->get_ParentSeriesGroup()->set_PieSplitBy ( Aspose::Slides::Charts::PieSplitType::ByPercentage); | |
series->get_ParentSeriesGroup()->set_PieSplitPosition ( 53); | |
// Write the presentation file to disk | |
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx); | |
تعيين ألوان شرائح المخطط الدائري تلقائيًا
Aspose.Slides لـ C++ توفر واجهة برمجة تطبيقات بسيطة لتعيين ألوان شرائح المخطط الدائري بشكل تلقائي. الكود النموذجي يطبق تعيين الخصائص المذكورة أعلاه.
- إنشاء نسخة من فئة Presentation.
- الوصول إلى الشريحة الأولى.
- إضافة مخطط مع البيانات الافتراضية.
- تعيين عنوان المخطط.
- تعيين السلسلة الأولى لعرض القيم.
- تعيين فهرس ورقة بيانات المخطط.
- الحصول على ورقة بيانات المخطط.
- حذف السلاسل والفئات المولدة افتراضيًا.
- إضافة فئات جديدة.
- إضافة سلاسل جديدة.
كتابة العرض التقديمي المعدل إلى ملف PPTX.
For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-C | |
// The path to the documents directory. | |
const String outPath = u"../out/AutomicPieChartSliceColors_out.pptx"; | |
//Instantiate Presentation class that represents PPTX file | |
SharedPtr<Presentation> pres = MakeObject<Presentation>(); | |
//Access first slide | |
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0); | |
// Add chart with default data | |
SharedPtr<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::Pie, 0, 0, 500, 500); | |
// Setting chart Title | |
chart->get_ChartTitle()->AddTextFrameForOverriding(u"Sample Title"); | |
chart->get_ChartTitle()->get_TextFrameForOverriding()->get_TextFrameFormat()->set_CenterText(NullableBool::True); | |
chart->get_ChartTitle()->set_Height(20); | |
chart->set_HasTitle(true); | |
// Delete default generated series and categories | |
chart->get_ChartData()->get_Series()->Clear(); | |
chart->get_ChartData()->get_Categories()->Clear(); | |
// Setting the index of chart data sheet | |
int defaultWorksheetIndex = 0; | |
// Getting the chart data worksheet | |
SharedPtr<IChartDataWorkbook> fact = chart->get_ChartData()->get_ChartDataWorkbook(); | |
// Add Catrgories | |
chart->get_ChartData()->get_Categories()->Add(fact->GetCell(defaultWorksheetIndex, 1, 0, ObjectExt::Box<System::String>(u"First Qtr"))); | |
chart->get_ChartData()->get_Categories()->Add(fact->GetCell(defaultWorksheetIndex, 2, 0, ObjectExt::Box<System::String>(u"2nd Qtr"))); | |
chart->get_ChartData()->get_Categories()->Add(fact->GetCell(defaultWorksheetIndex, 3, 0, ObjectExt::Box<System::String>(u"3ed Qtr"))); | |
// Now, Adding a new series | |
chart->get_ChartData()->get_Series()->Add(fact->GetCell(defaultWorksheetIndex, 0, 1, ObjectExt::Box<System::String>(u"Series 1")), chart->get_Type()); | |
// Take first chart series | |
SharedPtr<IChartSeries> series = chart->get_ChartData()->get_Series()->idx_get(0); | |
// Now populating series data | |
series->get_DataPoints()->AddDataPointForPieSeries(fact->GetCell(defaultWorksheetIndex, 1, 1, ObjectExt::Box<double>(20))); | |
series->get_DataPoints()->AddDataPointForPieSeries(fact->GetCell(defaultWorksheetIndex, 2, 1, ObjectExt::Box<double>(50))); | |
series->get_DataPoints()->AddDataPointForPieSeries(fact->GetCell(defaultWorksheetIndex, 3, 1, ObjectExt::Box<double>(30))); | |
chart->get_ChartData()->get_SeriesGroups()->idx_get(0)->set_IsColorVaried(true); | |
// Write the presentation file to disk | |
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx); | |