AxisDisplayUnit Class

Provides access to the scaling options of the display units for the value axis.
Inheritance Hierarchy

Namespace:  Aspose.Words.Drawing.Charts
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.4
public class AxisDisplayUnit

The AxisDisplayUnit type exposes the following members.

Public methodAxisDisplayUnit
Initializes a new instance of the AxisDisplayUnit class
Public propertyCode exampleCustomUnit
Gets or sets a user-defined divisor to scale display units on the value axis.
Public propertyDocument
Returns the Document the title holder belongs.
Public propertyCode exampleUnit
Gets or sets the scaling value of the display units as one of the predefined values.
Public methodEquals (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Public methodToString (Inherited from Object.)
Shows how to manipulate the tick marks and displayed values of a chart axis.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Insert a scatter chart, which is populated by default values
Shape shape = builder.InsertChart(ChartType.Scatter, 450, 250);
Chart chart = shape.Chart;

// Set they Y axis to show major ticks every at every 10 units and minor ticks at every 1 units
ChartAxis axis = chart.AxisY;
axis.MajorTickMark = AxisTickMark.Outside;
axis.MinorTickMark = AxisTickMark.Outside;

axis.MajorUnit = 10.0;
axis.MinorUnit = 1.0;

// Stretch out the bounds of the axis out to show 3 major ticks and 27 minor ticks
axis.Scaling.Minimum = new AxisBound(-10);
axis.Scaling.Maximum = new AxisBound(20);

// Do the same for the X-axis
axis = chart.AxisX;
axis.MajorTickMark = AxisTickMark.Inside;
axis.MinorTickMark = AxisTickMark.Inside;
axis.MajorUnit = 10.0;
axis.Scaling.Minimum = new AxisBound(-10);
axis.Scaling.Maximum = new AxisBound(30);

// We can also use this attribute to set minor tick spacing
axis.TickLabelSpacing = 2;
// We can define text alignment when axis tick labels are multi-line
// MS Word aligns them to the center by default
axis.TickLabelAlignment = ParagraphAlignment.Right;

// Get the axis to display values, but in millions
axis.DisplayUnit.Unit = AxisBuiltInUnit.Millions;

// Besides the built-in axis units we can choose from,
// we can also set the axis to display values in some custom denomination, using the following attribute
// The statement below is equivalent to the one above
axis.DisplayUnit.CustomUnit = 1000000.0;

doc.Save(ArtifactsDir + "Charts.ChartAxisDisplayUnit.docx");
See Also