حسابات المخطط
حساب القيم الفعلية لعناصر المخطط
توفر Aspose.Slides لـ C++ واجهة برمجة تطبيقات بسيطة للحصول على هذه الخصائص. سيساعدك ذلك على حساب القيم الفعلية لعناصر المخطط. تشمل القيم الفعلية موضع العناصر التي تنفذ واجهة IActualLayout (IActualLayout::get_ActualX(), IActualLayout::get_ActualY(), IActualLayout::get_ActualWidth(), IActualLayout::get_ActualHeight()) والقيم الفعلية للمحاور (IAxis::get_ActualMaxValue(), IAxis::get_ActualMinValue(), IAxis::get_ActualMajorUnit(), IAxis::get_ActualMinorUnit(), IAxis::get_ActualMajorUnitScale(), IAxis::get_ActualMinorUnitScale()).
auto pres = System::MakeObject<Presentation>(u"test.pptx");
auto chart = System::ExplicitCast<Chart>(pres->get_Slides()->idx_get(0)->get_Shapes()->AddChart(ChartType::ClusteredColumn, 100.0f, 100.0f, 500.0f, 350.0f));
chart->ValidateChartLayout();
double x = chart->get_PlotArea()->get_ActualX();
double y = chart->get_PlotArea()->get_ActualY();
double w = chart->get_PlotArea()->get_ActualWidth();
double h = chart->get_PlotArea()->get_ActualHeight();
// حفظ العرض التقديمي
pres->Save(u"Result.pptx", SaveFormat::Pptx);
حساب الموضع الفعلي لعناصر المخطط الأم
توفر Aspose.Slides لـ C++ واجهة برمجة تطبيقات بسيطة للحصول على هذه الخصائص. توفر طرق IActualLayout معلومات حول الموضع الفعلي لعنصر المخطط الأم. من الضروري استدعاء طريقة IChart::ValidateChartLayout() مسبقًا لملء الخصائص بالقيم الفعلية.
// إنشاء عرض تقديمي فارغ
auto pres = System::MakeObject<Presentation>();
auto chart = System::ExplicitCast<Chart>(pres->get_Slides()->idx_get(0)->get_Shapes()->AddChart(ChartType::ClusteredColumn, 100.0f, 100.0f, 500.0f, 350.0f));
chart->ValidateChartLayout();
double x = chart->get_PlotArea()->get_ActualX();
double y = chart->get_PlotArea()->get_ActualY();
double w = chart->get_PlotArea()->get_ActualWidth();
double h = chart->get_PlotArea()->get_ActualHeight();
إخفاء المعلومات من المخطط
تساعدك هذه الموضوع على فهم كيفية إخفاء المعلومات من المخطط. باستخدام Aspose.Slides لـ C++ يمكنك إخفاء العنوان، المحور العمودي، المحور الأفقي وخطوط الشبكة من المخطط. المثال البرمجي أدناه يوضح كيفية استخدام هذه الخصائص.
// The path to the documents directory. | |
const String outPath = u"../out/HideInformationFromChart.pptx"; | |
// Load the desired the presentation | |
SharedPtr<Presentation> pres = MakeObject<Presentation>(); | |
SharedPtr<IChart> chart = pres->get_Slides()->idx_get(0)->get_Shapes()->AddChart(ChartType::LineWithMarkers, 140, 118, 320, 370); | |
//Hiding chart Title | |
chart->set_HasTitle(false); | |
///Hiding Values axis | |
chart->get_Axes()->get_VerticalAxis()->set_IsVisible(false); | |
//Category Axis visibility | |
chart->get_Axes()->get_HorizontalAxis()->set_IsVisible(false); | |
//Hiding Legend | |
chart->set_HasLegend(false); | |
//Hiding MajorGridLines | |
chart->get_Axes()->get_HorizontalAxis()->get_MajorGridLinesFormat()->get_Line()->get_FillFormat()->set_FillType(FillType::NoFill); | |
for (int i = 0; i < chart->get_ChartData()->get_Series()->get_Count(); i++) | |
{ | |
chart->get_ChartData()->get_Series()->RemoveAt(i); | |
} | |
SharedPtr<IChartSeries> series = chart->get_ChartData()->get_Series()->idx_get(0); | |
series->get_Marker()->set_Symbol(MarkerStyleType::Circle); | |
series->get_Labels()->get_DefaultDataLabelFormat()->set_ShowValue(true); | |
series->get_Labels()->get_DefaultDataLabelFormat()->set_Position(LegendDataLabelPosition::Top); | |
series->get_Marker()->set_Size(15); | |
//Setting series line color | |
series->get_Format()->get_Line()->get_FillFormat()->set_FillType(FillType::Solid); | |
series->get_Format()->get_Line()->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Magenta()); | |
series->get_Format()->get_Line()->set_DashStyle(LineDashStyle::Solid); | |
//Write the PPTX 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 templatePath = u"../templates/ExistingChart.pptx"; | |
const String outPath = u"../out/DataRange_out.pptx"; | |
//Instantiate Presentation class that represents PPTX file | |
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath); | |
//Access first slide | |
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0); | |
// Add chart with default data | |
// SharedPtr<IChart> chart = DynamicCast<Aspose::Slides::Charts::IChart>(slide->get_Shapes()->idx_get(0)); | |
auto chart = DynamicCast<Aspose::Slides::Charts::Chart>(slide->get_Shapes()->idx_get(0)); | |
//Not working | |
//Set data range | |
// chart->get_ChartData()->SetRange("Sheet1!A1:B4"); | |
// Write the presentation file to disk | |
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx); | |