Aspose::Words::Drawing::Charts::ChartFormat class

ChartFormat class

Represents the formatting of a chart element. To learn more, visit the Working with Charts documentation article.

class ChartFormat : public Aspose::Words::Drawing::Core::IFillable,
                    public Aspose::Words::Drawing::Core::IStrokable

Methods

MethodDescription
get_Fill()Gets fill formatting for the parent chart element.
get_IsDefined()Gets a flag indicating whether any format is defined.
get_ShapeType()Gets or sets the shape type of the parent chart element.
get_Stroke()Gets line formatting for the parent chart element.
GetType() const override
Is(const System::TypeInfo&) const override
set_ShapeType(Aspose::Words::Drawing::Charts::ChartShapeType)Setter for Aspose::Words::Drawing::Charts::ChartFormat::get_ShapeType.
SetDefaultFill()Resets the fill of the chart element to have the default value.
static Type()

Examples

Shows how to use chart formating.

auto doc = System::MakeObject<Aspose::Words::Document>();
auto builder = System::MakeObject<Aspose::Words::DocumentBuilder>(doc);

System::SharedPtr<Aspose::Words::Drawing::Shape> shape = builder->InsertChart(Aspose::Words::Drawing::Charts::ChartType::Column, 432, 252);
System::SharedPtr<Aspose::Words::Drawing::Charts::Chart> chart = shape->get_Chart();

// Delete series generated by default.
System::SharedPtr<Aspose::Words::Drawing::Charts::ChartSeriesCollection> series = chart->get_Series();
series->Clear();

auto categories = System::MakeArray<System::String>({u"Category 1", u"Category 2"});
series->Add(u"Series 1", categories, System::MakeArray<double>({1, 2}));
series->Add(u"Series 2", categories, System::MakeArray<double>({3, 4}));

// Format chart background.
chart->get_Format()->get_Fill()->Solid(System::Drawing::Color::get_DarkSlateGray());

// Hide axis tick labels.
chart->get_AxisX()->get_TickLabels()->set_Position(Aspose::Words::Drawing::Charts::AxisTickLabelPosition::None);
chart->get_AxisY()->get_TickLabels()->set_Position(Aspose::Words::Drawing::Charts::AxisTickLabelPosition::None);

// Format chart title.
chart->get_Title()->get_Format()->get_Fill()->Solid(System::Drawing::Color::get_LightGoldenrodYellow());

// Format axis title.
chart->get_AxisX()->get_Title()->set_Show(true);
chart->get_AxisX()->get_Title()->get_Format()->get_Fill()->Solid(System::Drawing::Color::get_LightGoldenrodYellow());

// Format legend.
chart->get_Legend()->get_Format()->get_Fill()->Solid(System::Drawing::Color::get_LightGoldenrodYellow());

doc->Save(get_ArtifactsDir() + u"Charts.ChartFormat.docx");

See Also