Aspose::Words::Drawing::Charts::AxisTickLabels class

AxisTickLabels class

Represents properties of axis tick mark labels.

class AxisTickLabels : public Core::IChartItemTextProperties

Methods

MethodDescription
get_Alignment()Gets or sets text alignment of the axis tick labels.
get_Font()Provides access to font formatting of the tick labels.
get_IsAutoSpacing()Gets or sets a flag indicating whether to use automatic interval for drawing the tick labels.
get_Offset()Gets or sets the distance of the tick labels from the axis.
get_Orientation()Gets or sets the orientation of the tick label text.
get_Position()Gets or sets the position of the tick labels on the axis.
get_Rotation()Gets or sets the rotation of the tick labels in degrees.
get_Spacing()Gets or sets the interval at which the tick labels are drawn.
set_Alignment(Aspose::Words::ParagraphAlignment)Sets text alignment of the axis tick labels.
set_IsAutoSpacing(bool)Sets a flag indicating whether to use automatic interval for drawing the tick labels.
set_Offset(int32_t)Sets the distance of the tick labels from the axis.
set_Orientation(Aspose::Words::Drawing::ShapeTextOrientation)Sets the orientation of the tick label text.
set_Position(Aspose::Words::Drawing::Charts::AxisTickLabelPosition)Sets the position of the tick labels on the axis.
set_Rotation(int32_t)Sets the rotation of the tick labels in degrees.
set_Spacing(int32_t)Sets the interval at which the tick labels are drawn.

Examples

Shows how to insert a chart and modify the appearance of its axes.

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

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

// Clear the chart's demo data series to start with a clean chart.
chart->get_Series()->Clear();

// Insert a chart series with categories for the X-axis and respective numeric values for the Y-axis.
chart->get_Series()->Add(u"Aspose Test Series", System::MakeArray<System::String>({u"Word", u"PDF", u"Excel", 
    u"GoogleDocs", u"Note"}), System::MakeArray<double>({640, 320, 280, 120, 150}));

// Chart axes have various options that can change their appearance,
// such as their direction, major/minor unit ticks, and tick marks.
System::SharedPtr<Aspose::Words::Drawing::Charts::ChartAxis> xAxis = chart->get_AxisX();
xAxis->set_CategoryType(AxisCategoryType::Category);
xAxis->set_Crosses(AxisCrosses::Minimum);
xAxis->set_ReverseOrder(false);
xAxis->set_MajorTickMark(AxisTickMark::Inside);
xAxis->set_MinorTickMark(AxisTickMark::Cross);
xAxis->set_MajorUnit(10.0);
xAxis->set_MinorUnit(15.0);
xAxis->get_TickLabels()->set_Offset(50);
xAxis->get_TickLabels()->set_Position(AxisTickLabelPosition::Low);
xAxis->get_TickLabels()->set_IsAutoSpacing(false);
xAxis->set_TickMarkSpacing(1);

ASPOSE_ASSERT_EQ(xAxis->get_Document(), doc);

System::SharedPtr<Aspose::Words::Drawing::Charts::ChartAxis> yAxis = chart->get_AxisY();
yAxis->set_CategoryType(AxisCategoryType::Automatic);
yAxis->set_Crosses(AxisCrosses::Maximum);
yAxis->set_ReverseOrder(true);
yAxis->set_MajorTickMark(AxisTickMark::Inside);
yAxis->set_MinorTickMark(AxisTickMark::Cross);
yAxis->set_MajorUnit(100.0);
yAxis->set_MinorUnit(20.0);
yAxis->get_TickLabels()->set_Position(AxisTickLabelPosition::NextToAxis);
yAxis->get_TickLabels()->set_Alignment(ParagraphAlignment::Center);
yAxis->get_TickLabels()->get_Font()->set_Color(System::Drawing::Color::get_Red());
yAxis->get_TickLabels()->set_Spacing(1);

// Column charts do not have a Z-axis.
ASSERT_TRUE(System::TestTools::IsNull(chart->get_AxisZ()));

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

See Also