.netCHARTING v8.4 Documentation Send comments on this topic.
Axis Markers
Getting Started > General Tutorials > Axis Tutorials > Axis Markers

Glossary Item Box


The AxisMarker class can be used to highlight parts of a chart area along an axis. The axis marker can have a single value, a range, or even a CalendarPattern. An axis marker can also be attached to an element in cases where the marker is wanted on a category axis.

Axis markers can also be drawn on top of the chart elements when in 2D mode. This behavior can be specified by setting the AxisMarker.BringToFront property to true.

Single Value AxisMarker

An axis marker can take a number, DateTime, or string value to define it's position. This sample code snippet uses a number and string to insert markers.


AxisMarker am1 = new AxisMarker("Marker at 45",new Line(Color.Orange),45);

AxisMarker am2 = new AxisMarker("Text marker at 'Element 0'",new Line(Color.Green),"Element 0");
Chart.XAxis.Markers.Add(am1, am2);
[Visual Basic]

Dim am1 As New AxisMarker("Marker at 45",new Line(Color.Orange),45)

Dim am2 As New AxisMarker("Text marker at 'Element 0'",new Line(Color.Green),"Element 0")
Chart.XAxis.Markers.Add(am1, am2)




Range AxisMarker

Axis markers can also highlight a range on the chart. Even a string range.

String ranges are determined by string comparison where 2 is larger than 12.

AxisMarker am3 = new AxisMarker("20-30",new Background(Color.FromArgb(100,Color.LightBlue)),20,30);

AxisMarker am4 = new AxisMarker("'Element 1'-'Element 2'",new Background(Color.FromArgb(100,Color.LightBlue)),"Element 1","Element 2");
am4.Label.LineAlignment = StringAlignment.Near;
Chart.XAxis.Markers.Add(am3, am4);

[Visual Basic]

Dim am3 As New AxisMarker("20-30",New Background(Color.FromArgb(100,Color.LightBlue)),20,30)

Dim am4 As New AxisMarker("'Element 1'-'Element 2'",New Background(Color.FromArgb(100,Color.LightBlue)),"Element 1","Element 2")
am4.Label.LineAlignment = StringAlignment.Near
Chart.XAxis.Markers.Add(am3, am4)


Attached to an element

To attach an axis marker to an element simply instantiate one for the elements in question.

Markers attached to an element only appear on category axes and only if one is available.



myElement.AxisMarker = new AxisMarker("Attached to element 3",new Line(Color.Blue),0);

[Visual Basic]

myElement.AxisMarker = New AxisMarker("Attached to element 3",new Line(Color.Blue),0)




Calendar Pattern AxisMarker

A calendar pattern can be used to specify sections of time the axis marker is drawn on.

This example highlights the weekdays on a time x axis: 


CalendarPattern cp = new CalendarPattern(TimeInterval.Day,TimeInterval.Week,"0111110");
cp.AdjustmentUnit = TimeInterval.Day; 
AxisMarker am = new AxisMarker("",new Background(Color.FromArgb(100,Color.Orange)),0,0);
am.CalendarPattern = cp; 


[Visual Basic]

Dim cp As New CalendarPattern(TimeInterval.Day,TimeInterval.Week,"0111110")
cp.AdjustmentUnit = TimeInterval.Day
Dim am As New AxisMarker("",New Background(Color.FromArgb(100,Color.Orange)),0,0)
am.CalendarPattern = cp



 See Also: Calendar Pattern Tutorial

Sample: calendarPattern.aspx
©2016. All Rights Reserved.