Determine which Axis exists in the Chart

The following sample code demonstrates the use of Chart.has_axis(AxisType axis_type, bool is_primary) to determine if the sample chart has Primary and Secondary Category and Value Axis.

C# code to determine which axis exists in the chart

from aspose.cells import Workbook
from aspose.cells.charts import AxisType
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# The path to the documents directory.
dataDir = RunExamples.GetDataDir(".")
# Create workbook object
workbook = Workbook(dataDir + "source.xlsx")
# Access the first worksheet
worksheet = workbook.worksheets[0]
# Access the chart
chart = worksheet.charts[0]
# Determine which axis exists in chart
ret = chart.has_axis(AxisType.CATEGORY, True)
print("Has Primary Category Axis: " + str(ret))
ret = chart.has_axis(AxisType.CATEGORY, False)
print("Has Secondary Category Axis: " + str(ret))
ret = chart.has_axis(AxisType.VALUE, True)
print("Has Primary Value Axis: " + str(ret))
ret = chart.has_axis(AxisType.VALUE, False)
print("Has Secondary Value Axis: " + str(ret))

Console output generated by the sample code

The console output of the code has been shown below which displays true for Primary Category and Value Axis and false for Secondary Category and Value Axis.

Has Primary Category Axis: True

Has Secondary Category Axis: False

Has Primary Value Axis: True

Has Secondary Value Axis: False