How to Set Chart Axis Properties

If you want to work with chart axis, scaling, and display units for the value axis, please use ChartAxisAxisDisplayUnit, and AxisScaling classes.

The following code example shows how to define X and Y‑axis properties:

How to Set Date‑Time Value of Axis

The following code example shows how to set date/time values to axis properties:

How to Format Number Value of Axis

The following code example shows how to change the format of numbers on the value axis:

How to Set Bounds of Axis

The AxisBound class represents a minimum or maximum bound of axis values. Bound can be specified as a numeric, date‑time or a special “auto” value.

The following code example shows how to set the bounds of an axis:

How to Set Interval Unit Between Labels

The following code example shows how to set the interval unit between labels on an axis:

How to Hide Chart Axis

If you want to show or hide the chart axis, you can simply achieve this by setting the value of the set_Hidden property.

The following code example shows how to hide the Y‑axis of the chart:

How to Align Chart Label

If you want to set a text alignment for multi‑line labels, you can simply achieve this by setting the value of the TickLabelAlignment property. The following code example shows how to tick label alignment.


FAQ

  1. Q: How can I set date‑time values on a chart axis?
    A: Use the AxisScaling class to assign an array of System::DateTime values to the axis. Set the axis type to AxisType::DateTime and optionally define the major unit and base unit to control the spacing of the labels.

  2. Q: How do I change the number format displayed on the value axis?
    A: Create an AxisDisplayUnit object and assign it to the axis via ChartAxis::set_DisplayUnit. Then call AxisScaling::set_NumberFormat with a format string such as "#,##0.00" to control how numbers are rendered.

  3. Q: How can I hide a specific axis in a chart?
    A: Set the Hidden property of the desired ChartAxis to true (e.g., chart->get_Axes()->get_Y()->set_Hidden(true);). The axis will no longer be drawn, but its data remains available for calculations.

  4. Q: How do I set custom minimum and maximum bounds for an axis?
    A: Use the AxisBound class to create lower and upper bounds. Assign them to the axis with AxisScaling::set_Minimum and AxisScaling::set_Maximum. You can pass a numeric value, a DateTime, or AxisBound::Auto for automatic scaling.

  5. Q: How can I align multi‑line tick labels on an axis?
    A: Set the TickLabelAlignment property of the ChartAxis to one of the ParagraphAlignment values (e.g., ParagraphAlignment::Center). This aligns each line of the label according to the chosen alignment.