Axis labels

XLabel The main axis label provides the name for ILAxis. The name is displayed next to the axis line and automatically moves with the cube's rotation.

Configuring axis labels

Axis labels are accessed by the Label property of ILAxis. For example, to set the label's text for the X axis of an ILPanel ('panel') to "X Label" in a red, bold font, use the following statements:

panel.Axes.XAxis.Label.Text = "X Label";
panel.Axes.XAxis.Label.Font = new Font("Arial",10.0f, FontStyle.Bold); 
panel.Axes.XAxis.Label.Color = Color.Red; 

ILAxisLabel provides the following members, which are used to configure display properties for the label.

PropertyDescription
AlignmentAlign the label along the axis line.
ColorColor for the label
FontFont for the label
PaddingSpacing around the label
TextLabel text

Positioning the label

The Alignment property determines where to place the label along the main axis line. Possiblie values are contained in the AxisLabelAlign enumeration:

  • Center centers the label between minimum and maximum value,
  • Upper places the label near the upper axis limit and
  • Lower places the label near the lower axis limit.

Oversized labels

Axis labels are nicely prepared to render more than small text elements. The text for axis labels can span multiple lines, even very long lines are supported. However, you are responsible to manually place line breaks into the text. ILAxis automatically finds the optimal position for the label to fit into the controls bounds. If a nice location cannot be found, the label's orientation (horizontal/vertical) will also be adjusted.

The following example demonstrates, how to configure axis labels properties: text,font, color,size,alignment and padding. The X axis label is very large and spans multiple lines. For testing, run the example, enter some text in the textbox and move the camera by dragging the cube with the mouse. Watch the label dynamically changing position and/or orientation.

// configure X label
ILAxisLabel label = m_panel.Axes.XAxis.Label;
label.Color = Color.Green; 
label.Font = new Font("Times New Roman",12.0f,FontStyle.Italic); 
label.Text = "Change me in the textbox!"; 
label.Alignment = AxisLabelAlign.Lower; 
// configure Y label
label = m_panel.Axes.YAxis.Label; 
label.Font = new Font("Courier",08.0f,FontStyle.Regular);
label.Text = "Y label"; 
label.Alignment = AxisLabelAlign.Upper; 
label.Padding = 20; 

example7

Download the complete example as VS2005 solution here.


Valid CSS! Valid XHTML 1.0 Transitional