CategoryAxis
Type class
Extension for AxisBase, gets automatically populated if none has been specified.
Example
```js var chart = AmCharts.makeChart("chartdiv",{ ... "categoryAxis": { "gridPosition": "start" } });```Sources
This information about CategoryAxis is provided for reference only and is not available through exported packages and thus should not be imported or used on its own.
Inheritance
CategoryAxis extends AxisBase.
CategoryAxis is not extended by any other symbol.
Properties
autoRotateAngleType
numberAngle of label rotation, if the number of series exceeds autoRotateCount and parseDates is set to false.
autoRotateCountType
numberIf the number of category axis items will exceed the autoRotateCount, the labels will be rotated by autoRotateAngle degree. Works only if parseDates is false.
autoWrapType
booleanDefaultfalseSpecifies if axis labels (only when it is horizontal) should be wrapped if they don't fit in the allocated space. If axis is vertical, you should set axis.ignoreAxisWidth to true in order this feature to work.
categoryFunctionspecifies a method that returns the value that should be used as categoryValue for current item. If this property is set, the return value of the custom data function takes precedence over categoryField. When a chart calls this method, it passes category value, data item from chart's data provider and reference to categoryAxis: categoryFunction(category, dataItem, categoryAxis); This method can be used both when category axis parses dates and when it doesn't. If axis parses dates, your categoryFunction should return Date object. For example, if you have date strings in your data, you can use this method to convert these strings into Date objects.
classNameFieldType
stringIf this field is set and addClassNames is enabled, the category axis labels, ticks and grid will have this class name set.
NOTE: this will not work if the axis is date-based.
dateFormatsType
object[]Default[ { "period": "fff", "format": "JJ:NN:SS" }, { "period": "ss", "format": "JJ:NN:SS" }, { "period": "mm", "format": "JJ:NN" }, { "period": "hh", "format": "JJ:NN" }, { "period": "DD", "format": "MMM DD" }, { "period": "WW", "format": "MMM DD" }, { "period": "MM", "format": "MMM" }, { "period": "YYYY", "format": "YYYY" } ]Date formats of different periods. Possible period values: fff - milliseconds, ss - seconds, mm - minutes, hh - hours, DD - days, MM - months, WW - weeks, YYYY - years. Check this page for date formatting strings.
equalSpacingType
booleanDefaultfalseIn case your category axis values are Date objects and parseDates is set to true, the chart will parse dates and will place your data points at irregular intervals. However if you want dates to be parsed (displayed on the axis, baloons, etc), but data points to be placed at equal intervals (omiting dates with no data), set equalSpacing to true.
forceShowFieldType
stringField in data provider which specifies if the category value should always be shown. For example: categoryAxis.forceShowField = "forceShow";
And in data:
{category:"one", forceShow:true, value:100} Note, this works only when parseDates is set to false.
gridPositionType
stringDefaultmiddleSpecifies if a grid line is placed on the center of a cell or on the beginning of a cell. Possible values are: "start" and "middle" This setting doesn't work if parseDates is set to true.
labelColorFieldType
stringYou can use it to set color of a axis label. Works only with non-date-based data.
labelFunctionYou can use this function to format Category axis labels. If this function is set, then it is called with the following parameters passed:
if dates are not parsed:
labelFunction(valueText, serialDataItem, categoryAxis) if dates are parsed:
labelFunction(valueText, date, categoryAxis) Your function should return string which will be displayed on the axis.
minPeriodType
stringDefaultDDSpecifies the shortest period of your data. This should be set only if parseDates is set to "true". Possible period values: fff - milliseconds, ss - seconds, mm - minutes, hh - hours, DD - days, MM - months, YYYY - years.
It's also possible to supply a number for increments, i.e. "15mm" which will instruct the chart that your data is supplied in 15 minute increments.
parseDatesType
booleanDefaultfalseIn case your category axis values are Date objects, set this to true. In this case the chart will parse dates and will place your data points at irregular intervals. If you want dates to be parsed, but data points to be placed at equal intervals, set both parseDates and equalSpacing to true.
Note: we recommend using JavaScript timestamps to specify date/time. If you are specifying dates as strings in your data, i.e. "2015-01-05", we strongly recommend setting dataDateFormat as well.
Important: If this is set to
true, the data points needs to come pre-ordered in ascending order. Data with incorrect order might result in visual and functional glitches on the chart.positionType
stringDefaultbottomPossible values are: "top", "bottom", "left", "right". If axis is vertical, default position is "left". If axis is horizontal, default position is "bottom".
startOnAxisType
booleanDefaultfalseSpecifies whether the graph should start on axis or not. In case you display columns, it is recommended to set this to false. If parseDates is set to true, startOnAxis will allways be false, unless equalSpacing is set to true.
tickPositionType
stringDefaultmiddlePosition of a axis tick. Available settings: middle, start. Works only with non-date-based data.
twoLineModeType
booleanDefaultfalseWorks only when parseDates is set to true and equalSpacing is false. If you set it to true, at the position where bigger period changes, category axis will display date strings of bot small and big period, in two rows.
widthFieldType
stringYou can specify relative width for your columns using this field and produce Mekko chart using this new feature.
42 inherited items
autoGridCountType
booleanDefaulttrueInherited fromAxisBaseSpecifies whether number of gridCount is specified automatically, acoarding to the axis size.
axisAlphaType
numberDefault1Inherited fromAxisBaseAxis opacity. Value range is 0 - 1.
axisColorType
colorDefault#000000Inherited fromAxisBaseAxis color.
axisThicknessType
numberDefault1Inherited fromAxisBaseThickness of the axis.
boldLabelsType
booleanDefaultfalseInherited fromAxisBaseSpecifies if axis labels should be bold or not.
boldPeriodBeginningType
booleanDefaulttrueInherited fromAxisBaseWhen parse dates is on for the category axis, the chart will try to highlight the beginning of the periods, like month, in bold. Set this to false to disable the functionality.
centerLabelOnFullPeriodType
booleanDefaulttrueInherited fromAxisBaseThis setting works only when parseDates is set to true and equalSpacing is set to false. In case you set it to false, labels will never be centered between grid lines.
centerLabelsType
booleanDefaultfalseInherited fromAxisBaseForce-centers labels of date-based axis (in case it's category axis, equalSpacing must be false)
centerRotatedLabelsType
booleanDefaultfalseInherited fromAxisBaseIn case you have rotated labels on horizontal axis, you can force-center them using this property.
colorType
colorInherited fromAxisBaseColor of axis value labels. Will use chart's color if not set.
dashLengthType
numberDefault0Inherited fromAxisBaseLength of a dash. 0 means line is not dashed.
fillAlphaType
numberDefault0Inherited fromAxisBaseFill opacity. Every second space between grid lines can be filled with color. Set fillAlpha to a value greater than 0 to see the fills.
fillColorType
colorDefault#FFFFFFInherited fromAxisBaseFill color. Every second space between grid lines can be filled with color. Set fillAlpha to a value greater than 0 to see the fills.
firstDayOfWeekType
numberDefault1Inherited fromAxisBaseSets first day of the week. 0 is Sunday, 1 is Monday, etc.
fontSizeType
numberInherited fromAxisBaseSize of value labels text. Will use chart's fontSize if not set.
gridAlphaType
numberDefault0.15Inherited fromAxisBaseOpacity of grid lines.
gridColorType
colorDefault#000000Inherited fromAxisBaseColor of grid lines.
gridCountType
numberDefault5Inherited fromAxisBaseNumber of grid lines. In case this is value axis, or your categoryAxis parses dates, the number is approximate. The default value is 5. If you set autoGridCount to true, this property is ignored.
gridThicknessType
numberDefault1Inherited fromAxisBaseThickness of grid lines.
guidesType
Guide[]Default[]Inherited fromAxisBaseThe array of guides belonging to this axis.
ignoreAxisWidthType
booleanDefaultfalseInherited fromAxisBaseIf autoMargins of a chart is set to true, but you want this axis not to be measured when calculating margin, set ignoreAxisWidth to true.
insideType
booleanDefaultfalseInherited fromAxisBaseSpecifies whether values should be placed inside or outside plot area.
labelFrequencyType
numberDefault1Inherited fromAxisBaseFrequency at which labels should be placed. Doesn't work for CategoryAxis if parseDates is set to true.
labelOffsetType
numberDefault0Inherited fromAxisBaseYou can use it to adjust position of axes labels. Works both with CategoryAxis and ValueAxis.
labelRotationType
numberDefault0Inherited fromAxisBaseRotation angle of a label. Only horizontal axis' values can be rotated. If you set this for vertical axis, the setting will be ignored. Possible values from -90 to 90.
labelsEnabledType
booleanDefaulttrueInherited fromAxisBaseSpecifies whether axis displays category axis' labels and value axis' values.
listenersType
object[]Inherited fromAxisBaseYou can add listeners of events using this property. Example: listeners = [{"event":"clickItem", "method":handleEvent}];
markPeriodChangeType
booleanDefaulttrueInherited fromAxisBaseIf you set it to false, the start of longer periods won't use a different date format and won't be bold.
minHorizontalGapType
numberDefault75Inherited fromAxisBaseThis property is used when calculating grid count (when autoGridCount is true). It specifies minimum cell width required for one span between grid lines.
minorGridAlphaType
numberDefault0.07Inherited fromAxisBaseOpacity of minor grid. In order minor to be visible, you should set minorGridEnabled to true.
minorGridEnabledType
booleanDefaultfalseInherited fromAxisBaseSpecifies if minor grid should be displayed.
NOTE: If equalSpacing is set to true, this setting will be ignored.
minorTickLengthType
numberDefault0Inherited fromAxisBaseLength of minor grid tick.
minVerticalGapType
numberDefault35Inherited fromAxisBaseThis property is used when calculating grid count (when autoGridCount is true). It specifies minimum cell height required for one span between grid lines.
offsetType
numberDefault0Inherited fromAxisBaseThe distance of the axis to the plot area, in pixels. Negative values can also be used.
showFirstLabelType
booleanDefaulttrueInherited fromAxisBaseWhether to show first axis label or not. This works properly only on ValueAxis. With CategoryAxis it wont work 100%, it depends on the period, zooming, etc. There is no guaranteed way to force category axis to show or hide first label.
showLastLabelType
booleanDefaulttrueInherited fromAxisBaseWhether to show last axis label or not. This works properly only on ValueAxis. With CategoryAxis it wont work 100%, it depends on the period, zooming, etc. There is no guaranteed way to force category axis to show or hide last label.
tickLengthType
numberDefault5Inherited fromAxisBaseLength of the tick marks.
titleType
stringInherited fromAxisBaseTitle of the axis.
titleBoldType
booleanDefaulttrueInherited fromAxisBaseSpecifies if title should be bold or not.
titleColorType
colorInherited fromAxisBaseColor of axis title. Will use text color of chart if not set any.
titleFontSizeType
numberInherited fromAxisBaseFont size of axis title. Will use font size of chart plus two pixels if not set any.
titleRotationType
numberInherited fromAxisBaseRotation of axis title. Useful if you want to make vertical axis title to be shown from top to down.
Methods
categoryToCoordinate()Returns
Numberreturns coordinate of a category. Works only if parseDates is false. If parseDates is true, use dateToCoordinate method.
category - String
coordinateToDate()Returns
date - Date objectReturns Date of the coordinate, in case parseDates is set to true and equalSpacing is set to false.
coordinate - Number
dateToCoordinate()Returns
NumberReturns coordinate of the date, in case parseDates is set to true. if parseDates is false, use categoryToCoordinate method.
date - Date object
xToIndex()Returns
NumberReturns index of the category which is most close to specified coordinate.
x - coordinate
2 inherited items
Events
clickGuideParam { type:
"clickGuide", target:CategoryAxis} &{type: "clickGuide", guide:Guide, chart:AmRectangularChart}Dispatched when user clicks on a guide.
clickItemParam { type:
"clickItem", target:CategoryAxis} &{type: "clickItem", value:value, serialDataItem:SerialDataItem, axis:AxisBase, target:label, chart:AmRectangularChart, event:MouseEvent}Fired if user clicks on axis label.
rollOutGuideParam { type:
"rollOutGuide", target:CategoryAxis} &{type: "rollOutGuide", guide:Guide, chart:AmRectangularChart}Dispatched when user rolls-out of the guide.
rollOutItemParam { type:
"rollOutItem", target:CategoryAxis} &{type: "rollOutItem", value:value, serialDataItem:SerialDataItem, axis:AxisBase, target:label, chart:AmRectangularChart, event:MouseEvent}Fired if user rolls-out of the axis label.
rollOverGuideParam { type:
"rollOverGuide", target:CategoryAxis} &{type: "rollOverGuide", guide:Guide, chart:AmRectangularChart}Dispatched when user rolls-over some guide.
rollOverItemParam { type:
"rollOverItem", target:CategoryAxis} &{type: "rollOverItem", value:value, serialDataItem:SerialDataItem, axis:AxisBase, target:label, chart:AmRectangularChart, event:MouseEvent}Fired if user rolls-over axis label.