Animated Charts
Animation in Chart Series
If you want to animate a chart series, write the code according to the steps listed below:
- Load a presentation.
- Get reference of the chart object.
- Animate the series.
- Write the presentation file to disk.
In the example given below, we animated chart series.
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/AnimatingSeries.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 | |
auto chart = DynamicCast<Aspose::Slides::Charts::Chart>(slide->get_Shapes()->idx_get(0)); | |
// Animate series | |
slide->get_Timeline()->get_MainSequence()->AddEffect(chart, EffectType::Fade, EffectSubtype::None, EffectTriggerType::AfterPrevious); | |
auto sequence = DynamicCast<Aspose::Slides::Animation::Sequence>(slide->get_Timeline()->get_MainSequence()); | |
sequence->AddEffect(chart,EffectChartMajorGroupingType::BySeries, 0,EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious); | |
sequence->AddEffect(chart,EffectChartMajorGroupingType::BySeries, 1,EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious); | |
sequence->AddEffect(chart,EffectChartMajorGroupingType::BySeries, 2,EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious); | |
sequence->AddEffect(chart,EffectChartMajorGroupingType::BySeries, 3,EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious); | |
// Write the presentation file to disk | |
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx); | |
Animation in Chart Series Element
If you want to animate series elements, write the code according to the steps listed below:
- Load a presentation.
- Get reference of the chart object.
- Animate series elements.
- Write the presentation file to disk.
In the example given below, we have animated series' elements.
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/AnimatingSeriesElements.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 | |
auto chart = DynamicCast<Aspose::Slides::Charts::Chart>(slide->get_Shapes()->idx_get(0)); | |
// Animate series elements | |
slide->get_Timeline()->get_MainSequence()->AddEffect(chart, EffectType::Fade, EffectSubtype::None, EffectTriggerType::AfterPrevious); | |
auto sequence = DynamicCast<Aspose::Slides::Animation::Sequence>(slide->get_Timeline()->get_MainSequence()); | |
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInSeries, 0, 0, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious); | |
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInSeries, 0, 1, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious); | |
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInSeries, 0, 2, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious); | |
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInSeries, 0, 3, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious); | |
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInSeries, 1, 0, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious); | |
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInSeries, 1, 1, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious); | |
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInSeries, 1, 2, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious); | |
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInSeries, 1, 3, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious); | |
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInSeries, 2, 0, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious); | |
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInSeries, 2, 1, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious); | |
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInSeries, 2, 2, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious); | |
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInSeries, 2, 3, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious); | |
// Write the presentation file to disk | |
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx); | |
Animation in Chart Category
If you want to animate a chart series, write the code according to the steps listed below:
- Load a presentation.
- Get reference of the chart object.
- Animate the Category.
- Write the presentation file to disk.
In the example given below, we animated chart category.
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/AnimatingSeries.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 | |
auto chart = DynamicCast<Aspose::Slides::Charts::Chart>(slide->get_Shapes()->idx_get(0)); | |
// Animate series | |
slide->get_Timeline()->get_MainSequence()->AddEffect(chart, EffectType::Fade, EffectSubtype::None, EffectTriggerType::AfterPrevious); | |
auto sequence = DynamicCast<Aspose::Slides::Animation::Sequence>(slide->get_Timeline()->get_MainSequence()); | |
sequence->AddEffect(chart,EffectChartMajorGroupingType::BySeries, 0,EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious); | |
sequence->AddEffect(chart,EffectChartMajorGroupingType::BySeries, 1,EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious); | |
sequence->AddEffect(chart,EffectChartMajorGroupingType::BySeries, 2,EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious); | |
sequence->AddEffect(chart,EffectChartMajorGroupingType::BySeries, 3,EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious); | |
// Write the presentation file to disk | |
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx); | |
Animation in Chart Category Element
If you want to animate categories elements, write the code according to the steps listed below:
- Load a presentation.
- Get reference of the chart object.
- Animate categories elements.
- Write the presentation file to disk.
In the example given below, we have animated categories elements.
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/AnimatingCategoriesElements_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 | |
auto chart = DynamicCast<Aspose::Slides::Charts::Chart>(slide->get_Shapes()->idx_get(0)); | |
// Animate categories' elements | |
slide->get_Timeline()->get_MainSequence()->AddEffect(chart, EffectType::Fade, EffectSubtype::None, EffectTriggerType::AfterPrevious); | |
auto sequence = DynamicCast<Aspose::Slides::Animation::Sequence>(slide->get_Timeline()->get_MainSequence()); | |
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInCategory, 0, 0, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious); | |
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInCategory, 0, 1, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious); | |
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInCategory, 0, 2, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious); | |
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInCategory, 0, 3, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious); | |
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInCategory, 1, 0, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious); | |
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInCategory, 1, 1, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious); | |
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInCategory, 1, 2, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious); | |
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInCategory, 1, 3, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious); | |
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInCategory, 2, 0, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious); | |
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInCategory, 2, 1, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious); | |
sequence->AddEffect(chart, EffectChartMinorGroupingType:: ByElementInCategory, 2, 2, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious); | |
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInCategory, 2, 3, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious); | |
// Write the presentation file to disk | |
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx); |