Web Components Axis Gridlines

    All Ignite UI for Web Components 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 IgcCategoryChartComponent as well as IgcFinancialChartComponent 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 Web Components chart.

    Web Components Axis Gridlines Example

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

    Web Components 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 Web Components chart by setting the following properties:

    Axis Visuals Type Property Names Description
    Major Stroke Color string xAxisMajorStroke
    These properties set the color of axis major gridlines.
    Minor Stroke Color string xAxisMinorStroke
    These properties set the color of axis minor gridlines.
    Major Stroke Thickness number xAxisMajorStrokeThickness
    These properties set the thickness in pixels of the axis major gridlines.
    Minor Stroke Thickness number xAxisMinorStrokeThickness
    These properties set the thickness in pixels of the axis minor gridlines.
    Major Interval number xAxisInterval
    These properties set interval between axis major gridlines and labels.
    Minor Interval number xAxisMinorInterval
    These properties set interval between axis minor gridlines, if used.
    Axis Line Stroke Color string xAxisStroke
    These properties set the color of an axis line.
    Axis Stroke Thickness number xAxisStrokeThickness
    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 IgcDataChartComponent 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 IgcDataChartComponent with the above dash array properties set:

    Web Components 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:

    Web Components Axis Tickmarks Properties

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

    Axis Visuals Type Property Names Description
    Tick Stroke Color string xAxisTickStroke
    These properties set the color of the tickmarks.
    Tick Stroke Thickness number xAxisTickStrokeThickness
    These properties set the thickness of the axis tick marks.
    Tick Stroke Length number xAxisTickLength
    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:

    IgcDataChartComponent IgcCategoryChartComponent or IgcFinancialChartComponent
    AxesIgcNumericXAxisComponentinterval xAxisInterval (Major Interval)
    AxesIgcNumericYAxisComponentinterval yAxisInterval (Major Interval)
    AxesIgcNumericXAxisComponentminorInterval xAxisMinorInterval
    AxesIgcNumericYAxisComponentminorInterval yAxisMinorInterval
    AxesIgcNumericXAxisComponentmajorStroke xAxisMajorStroke
    AxesIgcNumericYAxisComponentmajorStroke yAxisMajorStroke
    AxesIgcNumericXAxisComponentmajorStrokeThickness xAxisMajorStrokeThickness
    AxesIgcNumericYAxisComponentmajorStrokeThickness yAxisMajorStrokeThickness
    AxesIgcNumericXAxisComponentminorStrokeThickness xAxisMinorStrokeThickness
    AxesIgcNumericYAxisComponentminorStrokeThickness yAxisMinorStrokeThickness
    AxesIgcNumericXAxisComponentstrokeThickness xAxisStrokeThickness
    AxesIgcNumericYAxisComponentstrokeThickness yAxisStrokeThickness
    AxesIgcNumericXAxisComponentstroke xAxisStroke (Axis Line Color)
    AxesIgcNumericYAxisComponentstroke yAxisStroke (Axis Line Color)
    AxesIgcNumericXAxisComponenttickLength xAxisTickLength
    AxesIgcNumericYAxisComponenttickLength yAxisTickLength
    AxesIgcNumericXAxisComponenttickStroke xAxisTickStroke
    AxesIgcNumericYAxisComponenttickStroke yAxisTickStroke
    AxesIgcNumericXAxisComponentstrip xAxisStrip (Space between Major Gridlines)
    AxesIgcNumericYAxisComponentstrip yAxisStrip (Space between Major Gridlines)