AxisDisplayUnitCustomUnit Property

Gets or sets a user-defined divisor to scale display units on the value axis.

Namespace:  Aspose.Words.Drawing.Charts
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntax
public double CustomUnit { get; set; }

Property Value

Type: Double
Remarks

The property is not supported by MS Office 2016 new charts. Default value is 1.

Setting this property sets the Unit property to Custom.

Examples
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