Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Sometimes, the user needs to know if a particular axis exists in the chart. For example, the user wants to know whether a secondary value axis exists in the chart. Some charts such as Pie, PieExploded, PiePie, PieBar, Pie3D, Pie3DExploded, Doughnut, DoughnutExploded, etc. do not have an axis.
Aspose.Cells provides the Chart.HasAxis(AxisType axisType, bool isPrimary) method to determine whether the chart has a particular axis.
The following sample code demonstrates the use of Chart.HasAxis(AxisType axisType, bool isPrimary) to determine whether the sample chart has primary and secondary category and value axes.
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
Aspose::Cells::Startup();
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C
// Create source directory path
U16String srcDir(u"..\\Data\\01_SourceDirectory\\");
// Create a workbook object
Workbook workbook(srcDir + u"source.xlsx");
// Access the first worksheet
Worksheet worksheet = workbook.GetWorksheets().Get(0);
// Access the chart
Chart chart = worksheet.GetCharts().Get(0);
// Determine which axis exists in the chart
bool ret = chart.HasAxis(AxisType::Category, true);
std::wcout << u"Has Primary Category Axis: " << ret << std::endl;
ret = chart.HasAxis(AxisType::Category, false);
std::wcout << u"Has Secondary Category Axis: " << ret << std::endl;
ret = chart.HasAxis(AxisType::Value, true);
std::wcout << u"Has Primary Value Axis: " << ret << std::endl;
ret = chart.HasAxis(AxisType::Value, false);
std::wcout << u"Has Secondary Value Axis: " << ret << std::endl;
Aspose::Cells::Cleanup();
}
The console output of the code is shown below; it displays true for the primary category and value axes and false for the secondary category and value axes.
Has Primary Category Axis: True
Has Secondary Category Axis: False
Has Primary Value Axis: True
Has Secondary Value Axis: FalseAnalyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.