Blazor Axis Gridlines
All Ignite UI for Blazor 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
IgbCategoryChart
as well asIgbFinancialChart
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 Blazor chart.
Blazor Axis Gridlines Example
This example shows how configure the axis gridline to display major and minor gridlines at specified intervals:
Blazor 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 Blazor 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 IgbDataChart
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 IgbDataChart
with the above dash array properties set:
Blazor 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:
Blazor Axis Tickmarks Properties
You can customize how the axis tickmarks are displayed in our Blazor 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: