Work with Chart Axis in Word Document

Share on FacebookTweet about this on TwitterShare on LinkedIn

The chart is a very useful feature to graphically represent or visualize any kind of data in a way to create maximum impact on target audiences. Charts allow users to see the results of the represented data in order to better understand and predict current and future data.

In a Word document, there are various types of charts available to work with based on the needs of users. To make a chart easier to understand, the chart title and axis titles can be added to any type of chart. Axis titles are typically available for all axes that can be displayed in a chart and most commonly used chart types have two axis. The X-axis along the bottom of the chart, usually the horizontal axis and the Y-axis along the left, usually the vertical axis.

How to Hide Chart Axis

In some cases, the user may need to hide the chart axis or anyone of them. Using Aspose.Words for .NET, this can simply be achieved by setting the value of ChartAxis.Hidden property for a specific axis to false. This property gets or sets a flag indicating whether this axis is hidden or not. The default value is false.

The following code snippet shows how to hide the Y-axis of the chart.

The resulting view of the chart is given below where Y-axis is hidden:

Multi-line Label Alignment

While working with ChartAxis, Aspose.Words for .NET provides an opportunity to set user-defined label alignment for the axis of the series. Microsoft Word aligns all the axis labels to the center by default as shown below:

The TickLabelAlignment property has been introduced under ChartAxis class for setting the label alignment. The ChartAxis class represents the axis options of the chart. The TickLabelAlignment property gets or sets text alignment of axis tick labels and it has effect only in case of multi-line labels. The default value is “ParagraphAlignment.Center“.

The following code snippet shows the working of TickLabelAlignment.

The resulting view of the chart is shown below: