エラーバー

エラーバーの追加

Aspose.Slides for C++は、エラーバーの値を管理するためのシンプルなAPIを提供します。サンプルコードは、カスタム値タイプを使用する場合に適用されます。値を指定するには、シリーズのDataPointsコレクション内の特定のデータポイントのErrorBarCustomValuesプロパティを使用します。

  1. Presentationクラスのインスタンスを作成します。
  2. 希望するスライドにバブルチャートを追加します。
  3. 最初のチャートシリーズにアクセスし、エラーバーX形式を設定します。
  4. 最初のチャートシリーズにアクセスし、エラーバーY形式を設定します。
  5. バーの値と形式を設定します。
  6. 変更されたプレゼンテーションを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/ErrorBars_out.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Access first slide
SharedPtr<ISlide> sld = pres->get_Slides()->idx_get(0);
// Add chart with default data
SharedPtr<IChart> chart = sld->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::Bubble, 0, 0, 500, 500, true);
// Adding custom Error chart and setting its format
SharedPtr<IChartSeries> series = chart->get_ChartData()->get_Series()->idx_get(0);
SharedPtr<IErrorBarsFormat> errBarX = series->get_ErrorBarsXFormat();
SharedPtr<IErrorBarsFormat> errBarY = series->get_ErrorBarsYFormat();
errBarX->set_IsVisible(true);
errBarY->set_IsVisible(true);
errBarX->set_ValueType(ErrorBarValueType::Fixed);
errBarX->set_Value( 0.1f);
errBarY->set_ValueType(ErrorBarValueType::Percentage);
errBarX->set_Value(5);
errBarX->set_Type (ErrorBarType::Plus);
errBarY->get_Format()->get_Line()->set_Width(2);
errBarX->set_HasEndCap ( true);
// Saving presentation
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);

カスタムエラーバーの追加

Aspose.Slides for C++は、カスタムエラーバーの値を管理するためのシンプルなAPIを提供します。サンプルコードは、IErrorBarsFormat.ValueTypeプロパティがCustomに等しい場合に適用されます。値を指定するには、シリーズのDataPointsコレクション内の特定のデータポイントのErrorBarCustomValuesプロパティを使用します。

  1. Presentationクラスのインスタンスを作成します。
  2. 希望するスライドにバブルチャートを追加します。
  3. 最初のチャートシリーズにアクセスし、エラーバーX形式を設定します。
  4. 最初のチャートシリーズにアクセスし、エラーバーY形式を設定します。
  5. チャートシリーズの個々のデータポイントにアクセスし、個々のシリーズのデータポイントのエラーバー値を設定します。
  6. バーの値と形式を設定します。
  7. 変更されたプレゼンテーションを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/ErrorBarsCustomValues_out.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Access first slide
SharedPtr<ISlide> sld = pres->get_Slides()->idx_get(0);
// Add chart with default data
SharedPtr<IChart> chart = sld->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::Bubble, 0, 0, 500, 500,true);
// Adding custom Error chart and setting its format
SharedPtr<IChartSeries> series = chart->get_ChartData()->get_Series()->idx_get(0);
SharedPtr<IErrorBarsFormat> errBarX = series->get_ErrorBarsXFormat();
SharedPtr<IErrorBarsFormat> errBarY = series->get_ErrorBarsYFormat();
errBarX->set_IsVisible(true);
errBarY->set_IsVisible(true);
errBarX->set_ValueType(ErrorBarValueType::Custom);
errBarY->set_ValueType(ErrorBarValueType::Custom);
// Accessing chart series data point and setting error bars values for individual point
SharedPtr<IChartDataPointCollection> points = series->get_DataPoints();
points->get_DataSourceTypeForErrorBarsCustomValues()->set_DataSourceTypeForXPlusValues(DataSourceType::DoubleLiterals);
points->get_DataSourceTypeForErrorBarsCustomValues()->set_DataSourceTypeForXMinusValues(DataSourceType::DoubleLiterals);
points->get_DataSourceTypeForErrorBarsCustomValues()->set_DataSourceTypeForYPlusValues (DataSourceType::DoubleLiterals);
points->get_DataSourceTypeForErrorBarsCustomValues()->set_DataSourceTypeForYMinusValues(DataSourceType::DoubleLiterals);
// Setting error bars for chart series points
for (int i = 0; i < points->get_Count(); i++)
{
points->idx_get(i)->get_ErrorBarsCustomValues()->get_XMinus()->set_AsLiteralDouble(i + 1);
points->idx_get(i)->get_ErrorBarsCustomValues()->get_XPlus()->set_AsLiteralDouble (i + 1);
points->idx_get(i)->get_ErrorBarsCustomValues()->get_YMinus()->set_AsLiteralDouble( i + 1);
points->idx_get(i)->get_ErrorBarsCustomValues()->get_YPlus()->set_AsLiteralDouble ( i + 1);
}
// Saving presentation
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);