Angular Axis Gridlines

    All Ignite UI for Angular charts include built-in capability to modify appearance of axis lines as well as frequency of major/minor gridlines and tickmarks that are rendered on the X-Axis and Y-Axis.

    [!Note] the following examples can be applied to IgxCategoryChartComponent as well as IgxFinancialChartComponent controls.

    Axis major gridlines are long lines that extend horizontally along the Y-Axis or vertically along the X-Axis from locations of axis labels, and they render through the plot area of the chart. Axis minor gridlines are lines that render between axis major gridlines.

    Axis tickmarks are displayed along all horizontal and vertical axes at each label at all major line positions of the Angular chart.

    Angular Axis Gridlines Example

    This example shows how configure the axis gridline to display major and minor gridlines at specified intervals:

    Angular Axis Gridlines Properties

    Setting the axis interval property specifies how often major gridlines and axis labels are rendered on an axis. Similarly, the axis minor interval property specifies how frequent minor gridlines are rendered on an axis.

    In order to display minor gridlines that correspond to minor interval, you need to set xAxisMinorStroke and xAxisMinorStrokeThickness properties on the axis. This is because minor gridlines do not have a default color or thickness and they will not be displayed without first assigning them.

    You can customize how the gridlines are displayed in your Angular chart by setting the following properties:

    Axis Visuals Type Property Names Description
    Major Stroke Color string xAxisMajorStroke
    yAxisMajorStroke
    These properties set the color of axis major gridlines.
    Minor Stroke Color string xAxisMinorStroke
    yAxisMinorStroke
    These properties set the color of axis minor gridlines.
    Major Stroke Thickness number xAxisMajorStrokeThickness
    yAxisMajorStrokeThickness
    These properties set the thickness in pixels of the axis major gridlines.
    Minor Stroke Thickness number xAxisMinorStrokeThickness
    yAxisMinorStrokeThickness
    These properties set the thickness in pixels of the axis minor gridlines.
    Major Interval number xAxisInterval
    yAxisInterval
    These properties set interval between axis major gridlines and labels.
    Minor Interval number xAxisMinorInterval
    yAxisMinorInterval
    These properties set interval between axis minor gridlines, if used.
    Axis Line Stroke Color string xAxisStroke
    yAxisStroke
    These properties set the color of an axis line.
    Axis Stroke Thickness number xAxisStrokeThickness
    yAxisStrokeThickness
    These properties set the thickness in pixels of an axis line.

    Regarding the Major and Minor Interval in the table above, it is important to note that the major interval for axis labels will also be set by this value, displaying one label at the point on the axis associated with the interval. The minor interval gridlines are always rendered between the major gridlines, and as such, the minor interval properties should always be set to something much smaller (usually 2-5 times smaller) than the value of the major Interval properties.

    On category axes, the intervals are represented as an index between first item and last category item. Generally, this value should equal to 10-20% of total numbers of category items for the major Interval so that all axis labels fit on axis so that they are not clipped by other axis labels. For minor intervals, this is represented as a fraction of the major interval properties. This value generally should equal between 0.25 and 0.5.

    On numeric axes, the interval values are represented as a double between axis minimum value and axis maximum value. By default, numeric axes will automatically calculate and find a nice and round interval based on axis minimum values and maximum value.

    On date time axes, this value is represented as time span between axis minimum value and axis maximum value.

    The following example demonstrates how to customize the gridlines by setting the properties above:

    The axes of the IgxDataChartComponent also have the ability to place a dash array on the major and minor gridlines by utilizing the majorStrokeDashArray and minorStrokeDashArray properties, respectively. The actual axis line can be dashed as well by setting the strokeDashArray property of the corresponding axis. These properties take an array of numbers that will describe the length of the dashes for the corresponding grid lines.

    The following example demonstrates a IgxDataChartComponent with the above dash array properties set:

    Angular Axis Tickmarks Example

    Axis tick marks are enabled by setting the xAxisTickLength and yAxisTickLength properties to a value greater than 0. These properties specifies the length of the line segments forming the tick marks.

    Tick marks are always extend from the axis line and point to the direction of the labels. Labels are offset by the value of the length of tickmarks to avoid overlapping. For example, with the yAxisTickLength property is set to 5, axis labels will be shifted left by that amount.

    The following example demonstrates how to customize the tickmarks by setting the properties above:

    Angular Axis Tickmarks Properties

    You can customize how the axis tickmarks are displayed in our Angular chats by setting the following properties:

    Axis Visuals Type Property Names Description
    Tick Stroke Color string xAxisTickStroke
    yAxisTickStroke
    These properties set the color of the tickmarks.
    Tick Stroke Thickness number xAxisTickStrokeThickness
    yAxisTickStrokeThickness
    These properties set the thickness of the axis tick marks.
    Tick Stroke Length number xAxisTickLength
    yAxisTickLength
    These properties set the length of the axis tick marks.

    Additional Resources

    You can find more information about related chart features in these topics:

    API References

    The following is a list of API members mentioned in the above sections:

    IgxDataChartComponent IgxCategoryChartComponent or IgxFinancialChartComponent
    AxesIgxNumericXAxisComponentinterval xAxisInterval (Major Interval)
    AxesIgxNumericYAxisComponentinterval yAxisInterval (Major Interval)
    AxesIgxNumericXAxisComponentminorInterval xAxisMinorInterval
    AxesIgxNumericYAxisComponentminorInterval yAxisMinorInterval
    AxesIgxNumericXAxisComponentmajorStroke xAxisMajorStroke
    AxesIgxNumericYAxisComponentmajorStroke yAxisMajorStroke
    AxesIgxNumericXAxisComponentmajorStrokeThickness xAxisMajorStrokeThickness
    AxesIgxNumericYAxisComponentmajorStrokeThickness yAxisMajorStrokeThickness
    AxesIgxNumericXAxisComponentminorStrokeThickness xAxisMinorStrokeThickness
    AxesIgxNumericYAxisComponentminorStrokeThickness yAxisMinorStrokeThickness
    AxesIgxNumericXAxisComponentstrokeThickness xAxisStrokeThickness
    AxesIgxNumericYAxisComponentstrokeThickness yAxisStrokeThickness
    AxesIgxNumericXAxisComponentstroke xAxisStroke (Axis Line Color)
    AxesIgxNumericYAxisComponentstroke yAxisStroke (Axis Line Color)
    AxesIgxNumericXAxisComponenttickLength xAxisTickLength
    AxesIgxNumericYAxisComponenttickLength yAxisTickLength
    AxesIgxNumericXAxisComponenttickStroke xAxisTickStroke
    AxesIgxNumericYAxisComponenttickStroke yAxisTickStroke
    AxesIgxNumericXAxisComponentstrip xAxisStrip (Space between Major Gridlines)
    AxesIgxNumericYAxisComponentstrip yAxisStrip (Space between Major Gridlines)