aspose.cells

Class Axis

Encapsulates the object that represents an axis of chart.

Example:

//Instantiating a Workbook object
$workbook = new cells\Workbook();
//Adding a new worksheet to the Excel object
$sheetIndex = $workbook->getWorksheets()->add();
//Obtaining the reference of the newly added worksheet by passing its sheet index
$worksheet = $workbook->getWorksheets()->get($sheetIndex);
//Adding a sample value to "A1" cell
$worksheet->getCells()->get("A1")->putValue(50);
//Adding a sample value to "A2" cell
$worksheet->getCells()->get("A2")->putValue(100);
//Adding a sample value to "A3" cell
$worksheet->getCells()->get("A3")->putValue(150);
//Adding a sample value to "B1" cell
$worksheet->getCells()->get("B1")->putValue(4);
//Adding a sample value to "B2" cell
$worksheet->getCells()->get("B2")->putValue(20);
//Adding a sample value to "B3" cell
$worksheet->getCells()->get("B3")->putValue(50);
//Adding a chart to the worksheet
$chartIndex = $worksheet->getCharts()->add(cells\ChartType::COLUMN, 5, 0, 25, 5);
//Accessing the instance of the newly added chart
$chart = $worksheet->getCharts()->get($chartIndex);
//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3"
$chart->getNSeries()->add("A1:B3", true);
//Set the max value of value axis
$chart->getValueAxis()->setMaxValue(200);
//Set the min value of value axis
$chart->getValueAxis()->setMinValue(0);
//Set the major unit
$chart->getValueAxis()->setMajorUnit(25);
//Category(X) axis crosses at the maxinum value
$chart->getValueAxis()->setCrossType(cells\CrossType::MAXIMUM);
//Set he number of categories or series between tick-mark labels-> 
$chart->getCategoryAxis()->setTickLabelSpacing(2);

Property Getters/Setters Summary
functiongetArea()
Gets the Area.
functiongetAxisBetweenCategories()
function
           Represents if the value axis crosses the category axis between categories.
functiongetAxisLabels()
Gets the labels of the axis after call Chart.Calculate() method.
functiongetAxisLine()
Gets the appearance of an Axis.
functiongetBaseUnitScale()
function
           Represents the base unit scale for the category axis. The value of the property is TimeUnit integer constant.
functiongetBins()
Represents bins on a chart(Histogram/Pareto) axis
functiongetCategoryType()
function
           Represents the category axis type. The value of the property is CategoryType integer constant.
functiongetCrossAt()
function
setCrossAt(value)
           Represents the point on the value axis where the category axis crosses it.
functiongetCrossType()
function
           Represents the CrossType on the specified axis where the other axis crosses. The value of the property is CrossType integer constant.
functiongetCustomUnit()
function
           Specifies a custom value for the display unit.
functiongetCustUnit()
function
           Specifies a custom value for the display unit.
functiongetDisplayUnit()
function
           Represents the unit label for the specified axis. The value of the property is DisplayUnitType integer constant.
functiongetDisplayUnitLabel()
Represents a unit label on an axis in the specified chart. Unit labels are useful for charting large values— for example, in the millions or billions.
functionhasMultiLevelLabels()
function
           Indicates whether the labels shall be shown as multi level.
functionisAutomaticMajorUnit()
function
           Indicates whether the major unit of the axis is automatically assigned.
functionisAutomaticMaxValue()
function
           Indicates whether the max value is automatically assigned.
functionisAutomaticMinorUnit()
function
           Indicates whether the minor unit of the axis is automatically assigned.
functionisAutomaticMinValue()
function
           Indicates whether the min value is automatically assigned.
functionisAutoTickLabelSpacing()
function
           Indicates whether the spacing of tick label is automatic
functionisBaseUnitAuto()
function
           Represents whether the base unit is automatic.
functionisDisplayUnitLabelShown()
function
           Represents if the display unit label is shown on the specified axis.
functionisLogarithmic()
function
           Represents if the value axis scale type is logarithmic or not.
functionisPlotOrderReversed()
function
           Represents if Microsoft Excel plots data points from last to first.
functionisVisible()
function
setVisible(value)
           Represents if the axis is visible.
functiongetLogBase()
function
setLogBase(value)
           Represents the logarithmic base. Default value is 10.Only applies for Excel2007.
functiongetMajorGridLines()
Represents major gridlines on a chart axis.
functiongetMajorTickMark()
function
           Represents the type of major tick mark for the specified axis. The value of the property is TickMarkType integer constant.
functiongetMajorUnit()
function
           Represents the major units for the axis.
functiongetMajorUnitScale()
function
           Represents the major unit scale for the category axis. The value of the property is TimeUnit integer constant.
functiongetMaxValue()
function
           Represents the maximum value on the value axis.
functiongetMinorGridLines()
Represents minor gridlines on a chart axis.
functiongetMinorTickMark()
function
           Represents the type of minor tick mark for the specified axis. The value of the property is TickMarkType integer constant.
functiongetMinorUnit()
function
           Represents the minor units for the axis.
functiongetMinorUnitScale()
function
           Represents the major unit scale for the category axis. The value of the property is TimeUnit integer constant.
functiongetMinValue()
function
           Represents the minimum value on the value axis.
functiongetTickLabelPosition()
function
           Represents the position of tick-mark labels on the specified axis. The value of the property is TickLabelPositionType integer constant.
functiongetTickLabels()
Returns a TickLabels object that represents the tick-mark labels for the specified axis.
functiongetTickLabelSpacing()
function
           Represents the number of categories or series between tick-mark labels. Applies only to category and series axes.
functiongetTickMarkSpacing()
function
           Returns or sets the number of categories or series between tick marks. Applies only to category and series axes.
functiongetTitle()
Gets the axis' title.
 
Method Summary
functiongetAxisTexts()
Gets the labels of the axis after call Chart.Calculate() method.
 

    • Property Getters/Setters Detail

      • getArea : Area 

        function getArea()
        
        Gets the Area.
      • isAutomaticMinValue/setAutomaticMinValue : boolean 

        function isAutomaticMinValue() / function setAutomaticMinValue(value)
        
        Indicates whether the min value is automatically assigned.
      • getMinValue/setMinValue : Object 

        function getMinValue() / function setMinValue(value)
        
        Represents the minimum value on the value axis. The minValue type only can be double or DateTime
      • isAutomaticMaxValue/setAutomaticMaxValue : boolean 

        function isAutomaticMaxValue() / function setAutomaticMaxValue(value)
        
        Indicates whether the max value is automatically assigned.
      • getMaxValue/setMaxValue : Object 

        function getMaxValue() / function setMaxValue(value)
        
        Represents the maximum value on the value axis. The maxValue type only can be double or DateTime
      • isAutomaticMajorUnit/setAutomaticMajorUnit : boolean 

        function isAutomaticMajorUnit() / function setAutomaticMajorUnit(value)
        
        Indicates whether the major unit of the axis is automatically assigned.
      • getMajorUnit/setMajorUnit : Number 

        function getMajorUnit() / function setMajorUnit(value)
        
        Represents the major units for the axis. The major units must be greater than zero.
      • isAutomaticMinorUnit/setAutomaticMinorUnit : boolean 

        function isAutomaticMinorUnit() / function setAutomaticMinorUnit(value)
        
        Indicates whether the minor unit of the axis is automatically assigned.
      • getMinorUnit/setMinorUnit : Number 

        function getMinorUnit() / function setMinorUnit(value)
        
        Represents the minor units for the axis. The minor units must be greater than zero.
      • getAxisLine : Line 

        function getAxisLine()
        
        Gets the appearance of an Axis.
      • getMajorTickMark/setMajorTickMark : Number 

        function getMajorTickMark() / function setMajorTickMark(value)
        
        Represents the type of major tick mark for the specified axis. The value of the property is TickMarkType integer constant.
      • getMinorTickMark/setMinorTickMark : Number 

        function getMinorTickMark() / function setMinorTickMark(value)
        
        Represents the type of minor tick mark for the specified axis. The value of the property is TickMarkType integer constant.
      • getTickLabelPosition/setTickLabelPosition : Number 

        function getTickLabelPosition() / function setTickLabelPosition(value)
        
        Represents the position of tick-mark labels on the specified axis. The value of the property is TickLabelPositionType integer constant.
      • getCrossAt/setCrossAt : Number 

        function getCrossAt() / function setCrossAt(value)
        
        Represents the point on the value axis where the category axis crosses it. The number should be a integer when it applies to category axis. And the value must be between 1 and 31999.
      • getCrossType/setCrossType : Number 

        function getCrossType() / function setCrossType(value)
        
        Represents the CrossType on the specified axis where the other axis crosses. The value of the property is CrossType integer constant.
      • getLogBase/setLogBase : Number 

        function getLogBase() / function setLogBase(value)
        
        Represents the logarithmic base. Default value is 10.Only applies for Excel2007.
      • isLogarithmic/setLogarithmic : boolean 

        function isLogarithmic() / function setLogarithmic(value)
        
        Represents if the value axis scale type is logarithmic or not.
      • isPlotOrderReversed/setPlotOrderReversed : boolean 

        function isPlotOrderReversed() / function setPlotOrderReversed(value)
        
        Represents if Microsoft Excel plots data points from last to first.
      • getAxisBetweenCategories/setAxisBetweenCategories : boolean 

        function getAxisBetweenCategories() / function setAxisBetweenCategories(value)
        
        Represents if the value axis crosses the category axis between categories. This property applies only to category axes, and it doesn't apply to 3-D charts.
      • getTickLabels : TickLabels 

        function getTickLabels()
        
        Returns a TickLabels object that represents the tick-mark labels for the specified axis.
      • getTickLabelSpacing/setTickLabelSpacing : Number 

        function getTickLabelSpacing() / function setTickLabelSpacing(value)
        
        Represents the number of categories or series between tick-mark labels. Applies only to category and series axes. The number must be between 1 and 31999.
      • isAutoTickLabelSpacing/setAutoTickLabelSpacing : boolean 

        function isAutoTickLabelSpacing() / function setAutoTickLabelSpacing(value)
        
        Indicates whether the spacing of tick label is automatic
      • getTickMarkSpacing/setTickMarkSpacing : Number 

        function getTickMarkSpacing() / function setTickMarkSpacing(value)
        
        Returns or sets the number of categories or series between tick marks. Applies only to category and series axes. The number must be between 1 and 31999.
      • getDisplayUnit/setDisplayUnit : Number 

        function getDisplayUnit() / function setDisplayUnit(value)
        
        Represents the unit label for the specified axis. The value of the property is DisplayUnitType integer constant.
      • getCustUnit/setCustUnit : Number 

        function getCustUnit() / function setCustUnit(value)
        
        Specifies a custom value for the display unit. NOTE: This property is now obsolete. Instead, please use Axis.CustomUnit property. This property will be removed 12 months later since January 2023. Aspose apologizes for any inconvenience you may have experienced.
      • getCustomUnit/setCustomUnit : Number 

        function getCustomUnit() / function setCustomUnit(value)
        
        Specifies a custom value for the display unit.
      • getDisplayUnitLabel : DisplayUnitLabel 

        function getDisplayUnitLabel()
        
        Represents a unit label on an axis in the specified chart. Unit labels are useful for charting large values— for example, in the millions or billions.
      • isDisplayUnitLabelShown/setDisplayUnitLabelShown : boolean 

        function isDisplayUnitLabelShown() / function setDisplayUnitLabelShown(value)
        
        Represents if the display unit label is shown on the specified axis. The default value is True.
      • getTitle : Title 

        function getTitle()
        
        Gets the axis' title.
      • getCategoryType/setCategoryType : Number 

        function getCategoryType() / function setCategoryType(value)
        
        Represents the category axis type. The value of the property is CategoryType integer constant.
      • getBaseUnitScale/setBaseUnitScale : Number 

        function getBaseUnitScale() / function setBaseUnitScale(value)
        
        Represents the base unit scale for the category axis. The value of the property is TimeUnit integer constant.Setting this property only takes effect when the CategoryType property is set to TimeScale.
      • isBaseUnitAuto/setBaseUnitAuto : boolean 

        function isBaseUnitAuto() / function setBaseUnitAuto(value)
        
        Represents whether the base unit is automatic.
      • getMajorUnitScale/setMajorUnitScale : Number 

        function getMajorUnitScale() / function setMajorUnitScale(value)
        
        Represents the major unit scale for the category axis. The value of the property is TimeUnit integer constant.

        Example:

        $workbook = new cells\Workbook();
        //Adding a new worksheet to the Excel object
        $sheetIndex = $workbook->getWorksheets()->add();
        //Obtaining the reference of the newly added worksheet by passing its sheet index
        $worksheet = $workbook->getWorksheets()->get($sheetIndex);
        //Adding a sample value to "A1" cell
        $worksheet->getCells()->get("A1")->putValue(50);
        //Adding a sample value to "A2" cell
        $worksheet->getCells()->get("A2")->putValue(100);
        //Adding a sample value to "A3" cell
        $worksheet->getCells()->get("A3")->putValue(150);
        //Adding a sample value to "B1" cell
        $worksheet->getCells()->get("B1")->putValue(4);
        //Adding a sample value to "B2" cell
        $worksheet->getCells()->get("B2")->putValue(20);
        //Adding a sample value to "B3" cell
        $worksheet->getCells()->get("B3")->putValue(50);
        //Adding a chart to the worksheet
        $chartIndex = $worksheet->getCharts()->add(cells\ChartType::COLUMN, 5, 0, 25, 5);
        //Accessing the instance of the newly added chart
        $chart = $worksheet->getCharts()->get($chartIndex);
        $chart->getNSeries()->add("A1:B3", true);
        $chart->getCategoryAxis()->setCategoryType(cells\CategoryType::TIME_SCALE);
        $chart->getCategoryAxis()->setMajorUnitScale(cells\TimeUnit::MONTHS);
        $chart->getCategoryAxis()->setMajorUnit(2);
      • getMinorUnitScale/setMinorUnitScale : Number 

        function getMinorUnitScale() / function setMinorUnitScale(value)
        
        Represents the major unit scale for the category axis. The value of the property is TimeUnit integer constant.

        Example:

        $workbook = new cells\Workbook();
        //Adding a new worksheet to the Excel object
        $sheetIndex = $workbook->getWorksheets()->add();
        //Obtaining the reference of the newly added worksheet by passing its sheet index
        $worksheet = $workbook->getWorksheets()->get($sheetIndex);
        //Adding a sample value to "A1" cell
        $worksheet->getCells()->get("A1")->putValue(50);
        //Adding a sample value to "A2" cell
        $worksheet->getCells()->get("A2")->putValue(100);
        //Adding a sample value to "A3" cell
        $worksheet->getCells()->get("A3")->putValue(150);
        //Adding a sample value to "B1" cell
        $worksheet->getCells()->get("B1")->putValue(4);
        //Adding a sample value to "B2" cell
        $worksheet->getCells()->get("B2")->putValue(20);
        //Adding a sample value to "B3" cell
        $worksheet->getCells()->get("B3")->putValue(50);
        //Adding a chart to the worksheet
        $chartIndex = $worksheet->getCharts()->add(cells\ChartType::COLUMN, 5, 0, 25, 5);
        //Accessing the instance of the newly added chart
        $chart = $worksheet->getCharts()->get($chartIndex);
        $chart->getNSeries()->add("A1:B3", true);
        $chart->getCategoryAxis()->setCategoryType(cells\CategoryType::TIME_SCALE);
        $chart->getCategoryAxis()->setMinorUnitScale(cells\TimeUnit::MONTHS);
        $chart->getCategoryAxis()->setMinorUnit(2);
      • isVisible/setVisible : boolean 

        function isVisible() / function setVisible(value)
        
        Represents if the axis is visible.
      • getMajorGridLines : Line 

        function getMajorGridLines()
        
        Represents major gridlines on a chart axis.

        Example:

        $workbook = new cells\Workbook();
        //Adding a new worksheet to the Excel object
        $sheetIndex = $workbook->getWorksheets()->add();
        //Obtaining the reference of the newly added worksheet by passing its sheet index
        $worksheet = $workbook->getWorksheets()->get($sheetIndex);
        //Adding a sample value to "A1" cell
        $worksheet->getCells()->get("A1")->putValue(50);
        //Adding a sample value to "A2" cell
        $worksheet->getCells()->get("A2")->putValue(100);
        //Adding a sample value to "A3" cell
        $worksheet->getCells()->get("A3")->putValue(150);
        //Adding a sample value to "B1" cell
        $worksheet->getCells()->get("B1")->putValue(4);
        //Adding a sample value to "B2" cell
        $worksheet->getCells()->get("B2")->putValue(20);
        //Adding a sample value to "B3" cell
        $worksheet->getCells()->get("B3")->putValue(50);
        //Adding a chart to the worksheet
        $chartIndex = $worksheet->getCharts()->add(cells\ChartType::COLUMN, 5, 0, 25, 5);
        //Accessing the instance of the newly added chart
        $chart = $worksheet->getCharts()->get($chartIndex);
        $chart->getNSeries()->add("A1:B3", true);
        $chart->getValueAxis()->getMajorGridLines()->setVisible(false);
        $chart->getCategoryAxis()->getMajorGridLines()->setVisible(true);
      • getMinorGridLines : Line 

        function getMinorGridLines()
        
        Represents minor gridlines on a chart axis.
      • hasMultiLevelLabels/setHasMultiLevelLabels : boolean 

        function hasMultiLevelLabels() / function setHasMultiLevelLabels(value)
        
        Indicates whether the labels shall be shown as multi level. Only valid for category axis.
      • getAxisLabels : ArrayList 

        function getAxisLabels()
        
        Gets the labels of the axis after call Chart.Calculate() method. NOTE: This member is now obsolete. Instead, please use Axis.GetAxisTexts method. This property will be removed 12 months later since November 2023. Aspose apologizes for any inconvenience you may have experienced.
      • getBins : AxisBins 

        function getBins()
        
        Represents bins on a chart(Histogram/Pareto) axis
    • Method Detail

      • getAxisTexts

        function getAxisTexts()
        Gets the labels of the axis after call Chart.Calculate() method.