Class Axis
The Axis class is an abstract base class that encompasses all properties and methods required to define a graph Axis.
Inherited Members
Namespace: ZedGraph
Assembly: ZedGraph.dll
Syntax
[Serializable]
public abstract class Axis : ISerializable, ICloneable
Remarks
This class is inherited by the XAxis, YAxis, and Y2Axis classes to define specific characteristics for those types.
Constructors
| Improve this Doc View SourceAxis()
Default constructor for Axis that sets all axis properties to default values as defined in the Axis.Default class.
Declaration
public Axis()
Axis(SerializationInfo, StreamingContext)
Constructor for deserializing objects
Declaration
protected Axis(SerializationInfo info, StreamingContext context)
Parameters
Type | Name | Description |
---|---|---|
SerializationInfo | info | A SerializationInfo instance that defines the serialized data |
StreamingContext | context | A StreamingContext instance that contains the serialized data |
Axis(String)
Constructor for Axis that sets all axis properties to default values as defined in the Axis.Default class, except for the Title.
Declaration
public Axis(string title)
Parameters
Type | Name | Description |
---|---|---|
String | title | A string containing the axis title |
Axis(Axis)
The Copy Constructor.
Declaration
public Axis(Axis rhs)
Parameters
Type | Name | Description |
---|---|---|
Axis | rhs | The Axis object from which to copy |
Fields
| Improve this Doc View Source_isAxisSegmentVisible
Private fields for the Axis attributes. Use the public properties IsVisible, IsAxisSegmentVisible for access to these values.
Declaration
[CLSCompliant(false)]
protected bool _isAxisSegmentVisible
Field Value
Type | Description |
---|---|
Boolean |
_isVisible
Private fields for the Axis attributes. Use the public properties IsVisible, IsAxisSegmentVisible for access to these values.
Declaration
[CLSCompliant(false)]
protected bool _isVisible
Field Value
Type | Description |
---|---|
Boolean |
_title
Declaration
[CLSCompliant(false)]
protected AxisLabel _title
Field Value
Type | Description |
---|---|
AxisLabel |
schema
Current schema value that defines the version of the serialized file
Declaration
public const int schema = 10
Field Value
Type | Description |
---|---|
Int32 |
Tag
A tag object for use by the user. This can be used to store additional information associated with the Axis. ZedGraph does not use this value for any purpose.
Declaration
public object Tag
Field Value
Type | Description |
---|---|
Object |
Remarks
Note that, if you are going to Serialize ZedGraph data, then any type that you store in Tag must be a serializable type (or it will cause an exception).
Properties
| Improve this Doc View SourceAxisGap
The size of the gap between multiple axes (see YAxisList and Y2AxisList).
Declaration
public float AxisGap { get; set; }
Property Value
Type | Description |
---|---|
Single | The axis gap is measured in points (1/72 inch) |
Remarks
This size will be scaled according to the CalcScaleFactor() for the GraphPane
See Also
| Improve this Doc View SourceColor
The color to use for drawing this Axis.
Declaration
public Color Color { get; set; }
Property Value
Type | Description |
---|---|
Color | The color is defined using the Color class |
Remarks
This affects only the axis segment (see IsAxisSegmentVisible), since the Title, Scale, MajorTic, MinorTic, MajorGrid, and MinorGrid all have their own color specification.
See Also
| Improve this Doc View SourceCross
Gets or sets the scale value at which this axis should cross the "other" axis.
Declaration
public double Cross { get; set; }
Property Value
Type | Description |
---|---|
Double | The value is defined in user scale units |
Remarks
This property allows the axis to be shifted away from its default location. For example, for a graph with an X range from -100 to +100, the Y Axis can be located at the X=0 value rather than the left edge of the ChartRect. This value can be set automatically based on the state of CrossAuto. If this value is set manually, then CrossAuto will also be set to false. The "other" axis is the axis the handles the second dimension for the graph. For the XAxis, the "other" axis is the YAxis. For the YAxis or Y2Axis, the "other" axis is the XAxis.
See Also
| Improve this Doc View SourceCrossAuto
Gets or sets a value that determines whether or not the Cross value is set automatically.
Declaration
public bool CrossAuto { get; set; }
Property Value
Type | Description |
---|---|
Boolean | Set to true to have ZedGraph put the axis in the default location, or false to specify the axis location manually with a Cross value. |
See Also
| Improve this Doc View SourceIsAxisSegmentVisible
Gets or sets a property that determines whether or not the axis segment (the line that represents the axis itself) is drawn.
Declaration
public bool IsAxisSegmentVisible { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Remarks
Under normal circumstances, this value won't affect the appearance of the display because the Axis segment is overlain by the Axis border (see Border). However, when the border is not visible, or when CrossAuto is set to false, this value will make a difference.
IsVisible
This property determines whether or not the Axis is shown.
Declaration
public bool IsVisible { get; set; }
Property Value
Type | Description |
---|---|
Boolean | true to show the axis, false to disable all drawing of this axis |
Remarks
Note that even if the axis is not visible, it can still be actively used to draw curves on a graph, it will just be invisible to the user
See Also
| Improve this Doc View SourceMajorGrid
Gets a reference to the MajorGrid class that contains the properties of the major grid.
Declaration
public MajorGrid MajorGrid { get; }
Property Value
Type | Description |
---|---|
MajorGrid |
MajorTic
Gets a reference to the MajorTic class instance for this Axis. This class stores all the major tic settings.
Declaration
public MajorTic MajorTic { get; }
Property Value
Type | Description |
---|---|
MajorTic |
MinorGrid
Gets a reference to the MinorGrid class that contains the properties of the minor grid.
Declaration
public MinorGrid MinorGrid { get; }
Property Value
Type | Description |
---|---|
MinorGrid |
MinorTic
Gets a reference to the MinorTic class instance for this Axis. This class stores all the minor tic settings.
Declaration
public MinorTic MinorTic { get; }
Property Value
Type | Description |
---|---|
MinorTic |
MinSpace
Gets or sets the minimum axis space allocation.
Declaration
public float MinSpace { get; set; }
Property Value
Type | Description |
---|---|
Single |
Remarks
This term, expressed in points (1/72 inch) and scaled according to CalcScaleFactor() for the GraphPane, determines the minimum amount of space an axis must have between the Rect and the Rect. This minimum space applies whether IsVisible is true or false.
Scale
Declaration
public Scale Scale { get; }
Property Value
Type | Description |
---|---|
Scale |
Title
Declaration
public AxisLabel Title { get; set; }
Property Value
Type | Description |
---|---|
AxisLabel | the title is a string value |
Remarks
The title normally shows the basis and dimensions of the scale range, such as "Time (Years)". The title is only shown if the IsVisible property is set to true. If the Title text is empty, then no title is shown, and no space is "reserved" for the title on the graph.
See Also
| Improve this Doc View SourceType
Declaration
public AxisType Type { get; set; }
Property Value
Type | Description |
---|---|
AxisType |
Remarks
See Also
Methods
| Improve this Doc View SourceCalcSpace(Graphics, GraphPane, Single, out Single)
Calculate the space required (pixels) for this Axis object.
Declaration
public float CalcSpace(Graphics g, GraphPane pane, float scaleFactor, out float fixedSpace)
Parameters
Type | Name | Description |
---|---|---|
Graphics | g | A graphic device object to be drawn into. This is normally e.Graphics from the PaintEventArgs argument to the Paint() method. |
GraphPane | pane | A reference to the GraphPane object that is the parent or owner of this object. |
Single | scaleFactor | The scaling factor to be used for rendering objects. This is calculated and passed down by the parent GraphPane object using the CalcScaleFactor() method, and is used to proportionally adjust font sizes, etc. according to the actual size of the graph. |
Single | fixedSpace | The amount of space (pixels) at the edge of the ChartRect that is always required for this axis, even if the axis is shifted by the Cross value. |
Returns
Type | Description |
---|---|
Single | Returns the space, in pixels, required for this axis (between the rect and ChartRect) |
Remarks
This is the total space (vertical space for the X axis, horizontal space for the Y axes) required to contain the axis. If Cross is zero, then this space will be the space required between the Rect and the Rect. This method sets the internal values of ZedGraph.Axis._tmpSpace for use by the CalcChartRect(Graphics) method.
Draw(Graphics, GraphPane, Single, Single)
Declaration
public void Draw(Graphics g, GraphPane pane, float scaleFactor, float shiftPos)
Parameters
Type | Name | Description |
---|---|---|
Graphics | g | A graphic device object to be drawn into. This is normally e.Graphics from the PaintEventArgs argument to the Paint() method. |
GraphPane | pane | A reference to the GraphPane object that is the parent or owner of this object. |
Single | scaleFactor | The scaling factor to be used for rendering objects. This is calculated and passed down by the parent GraphPane object using the CalcScaleFactor() method, and is used to proportionally adjust font sizes, etc. according to the actual size of the graph. |
Single | shiftPos | The number of pixels to shift to account for non-primary axis position (e.g., the second, third, fourth, etc. YAxis or Y2Axis. |
Remarks
This method is normally only called by the Draw method of the parent GraphPane object.
DrawMinorTics(Graphics, GraphPane, Double, Single, Single, Single)
Draw the minor tic marks as required for this Axis.
Declaration
public void DrawMinorTics(Graphics g, GraphPane pane, double baseVal, float shift, float scaleFactor, float topPix)
Parameters
Type | Name | Description |
---|---|---|
Graphics | g | A graphic device object to be drawn into. This is normally e.Graphics from the PaintEventArgs argument to the Paint() method. |
GraphPane | pane | A reference to the GraphPane object that is the parent or owner of this object. |
Double | baseVal | The scale value for the first major tic position. This is the reference point for all other tic marks. |
Single | shift | The number of pixels to shift this axis, based on the value of Cross. A positive value is into the ChartRect relative to the default axis position. |
Single | scaleFactor | The scaling factor to be used for rendering objects. This is calculated and passed down by the parent GraphPane object using the CalcScaleFactor() method, and is used to proportionally adjust font sizes, etc. according to the actual size of the graph. |
Single | topPix | The pixel location of the far side of the ChartRect from this axis. This value is the ChartRect.Height for the XAxis, or the ChartRect.Width for the YAxis and Y2Axis. |
DrawTitle(Graphics, GraphPane, Single, Single)
Draw the title for this Axis.
Declaration
public void DrawTitle(Graphics g, GraphPane pane, float shiftPos, float scaleFactor)
Parameters
Type | Name | Description |
---|---|---|
Graphics | g | A graphic device object to be drawn into. This is normally e.Graphics from the PaintEventArgs argument to the Paint() method. |
GraphPane | pane | A reference to the GraphPane object that is the parent or owner of this object. |
Single | shiftPos | The number of pixels to shift this axis, based on the value of Cross. A positive value is into the ChartRect relative to the default axis position. |
Single | scaleFactor | The scaling factor to be used for rendering objects. This is calculated and passed down by the parent GraphPane object using the CalcScaleFactor() method, and is used to proportionally adjust font sizes, etc. according to the actual size of the graph. |
Remarks
On entry, it is assumed that the graphics transform has been configured so that the origin is at the left side of this axis, and the axis is aligned along the X coordinate direction.
GetCrossAxis(GraphPane)
Gets the "Cross" axis that corresponds to this axis.
Declaration
public abstract Axis GetCrossAxis(GraphPane pane)
Parameters
Type | Name | Description |
---|---|---|
GraphPane | pane | A reference to the GraphPane object that is the parent or owner of this object. |
Returns
Type | Description |
---|---|
Axis |
Remarks
The cross axis is the axis which determines the of this Axis when the Cross property is used. The cross axis for any XAxis or X2Axis is always the primary YAxis, and the cross axis for any YAxis or Y2Axis is always the primary XAxis.
GetObjectData(SerializationInfo, StreamingContext)
Populates a SerializationInfo instance with the data needed to serialize the target object
Declaration
[SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
Parameters
Type | Name | Description |
---|---|---|
SerializationInfo | info | A SerializationInfo instance that defines the serialized data |
StreamingContext | context | A StreamingContext instance that contains the serialized data |
ResetAutoScale(GraphPane, Graphics)
Restore the scale ranging to automatic mode, and recalculate the Axis scale ranges
Declaration
public void ResetAutoScale(GraphPane pane, Graphics g)
Parameters
Type | Name | Description |
---|---|---|
GraphPane | pane | A reference to the GraphPane object that is the parent or owner of this object. |
Graphics | g | A graphic device object to be drawn into. This is normally e.Graphics from the PaintEventArgs argument to the Paint() method. |
See Also
| Improve this Doc View SourceSetMinSpaceBuffer(Graphics, GraphPane, Single, Boolean)
This method will set the MinSpace property for this Axis using the currently required space multiplied by a fraction ().
Declaration
public void SetMinSpaceBuffer(Graphics g, GraphPane pane, float bufferFraction, bool isGrowOnly)
Parameters
Type | Name | Description |
---|---|---|
Graphics | g | A graphic device object to be drawn into. This is normally e.Graphics from the PaintEventArgs argument to the Paint() method. |
GraphPane | pane | A reference to the GraphPane object that is the parent or owner of this object. |
Single | bufferFraction | The amount of space to allocate for the axis, expressed as a fraction of the currently required space. For example, a value of 1.2 would allow for 20% extra above the currently required space. |
Boolean | isGrowOnly | If true, then this method will only modify the MinSpace property if the calculated result is more than the current value. |
Remarks
The currently required space is calculated using CalcSpace(Graphics, GraphPane, Single, out Single), and is based on current data ranges, font sizes, etc. The "space" is actually the amount of space required to fit the tic marks, scale labels, and axis title.
SetTransformMatrix(Graphics, GraphPane, Single)
Setup the Transform Matrix to handle drawing of this Axis
Declaration
public abstract void SetTransformMatrix(Graphics g, GraphPane pane, float scaleFactor)
Parameters
Type | Name | Description |
---|---|---|
Graphics | g | A graphic device object to be drawn into. This is normally e.Graphics from the PaintEventArgs argument to the Paint() method. |
GraphPane | pane | A reference to the GraphPane object that is the parent or owner of this object. |
Single | scaleFactor | The scaling factor to be used for rendering objects. This is calculated and passed down by the parent GraphPane object using the CalcScaleFactor() method, and is used to proportionally adjust font sizes, etc. according to the actual size of the graph. |
Events
| Improve this Doc View SourceScaleFormatEvent
Subscribe to this event to handle custom formatting of the scale labels.
Declaration
public event Axis.ScaleFormatHandler ScaleFormatEvent
Event Type
Type | Description |
---|---|
Axis.ScaleFormatHandler |
ScaleTitleEvent
Allow customization of the title when the scale is very large Subscribe to this event to handle custom formatting of the scale axis label.
Declaration
public event Axis.ScaleTitleEventHandler ScaleTitleEvent
Event Type
Type | Description |
---|---|
Axis.ScaleTitleEventHandler |
Explicit Interface Implementations
| Improve this Doc View SourceICloneable.Clone()
Implement the ICloneable interface in a typesafe manner by just calling the typed version of Clone.
Declaration
object ICloneable.Clone()
Returns
Type | Description |
---|---|
Object | A deep copy of this object |
Remarks
Note that this method must be called with an explicit cast to ICloneable, and that it is inherently virtual. For example:
ParentClass foo = new ChildClass();
ChildClass bar = (ChildClass) ((ICloneable)foo).Clone();
Assume that ChildClass is inherited from ParentClass. Even though foo is declared with ParentClass, it is actually an instance of ChildClass. Calling the ICloneable implementation of Clone() on foo actually calls ChildClass.Clone() as if it were a virtual function.