Dundas Chart for Windows Forms
Setting Label Intervals
See Also Send comments on this topic.
Using Dundas Chart > Labels > Setting Label Intervals



Glossary Item Box

Overview

Axis labels are represented by the Axis.LabelStyle property. Both axes, and their associated labels, have the Interval, IntervalOffset, IntervalType, and IntervalOffsetType properties. This topic discusses setting these properties, and also provides you with tips and techniques to help you get started on creating engaging, informative, and attractive labels with a minimal effort.

 

Axis Label Properties

The following is a description of each of these four properties:

The properties of the axis elements (e.g. labels, etc.) are given higher priority than the Axis properties. For example, if the Axis.Interval is five, and the LabelStyle.Interval is three, then a value of three is used for the label's interval.

 

The following, are several important points concerning axis label intervals:

 

For more information on grid lines and tick marks, see the topic on Grid Lines and Tick Marks.

 

Code Samples

The following code samples have been included to help you get started.

Example

This example demonstrates how to set the primary X axis' minimum, maximum, interval, and interval offset values. We demonstrate how to display the axis' labels, major tick marks, and major grid lines every 20 units, with an offset of 10 units. It has been assumed that unless otherwise specified, default chart values are used.

Visual Basic Copy Code
Imports Dundas.Charting.WinControl
   ...
   
Chart1.ChartAreas("Default").AxisX.Minimum = 0
Chart1.ChartAreas("Default").AxisX.Maximum = 100
Chart1.ChartAreas("Default").AxisX.Interval = 20
Chart1.ChartAreas("Default").AxisX.IntervalOffset = 10

C# Copy Code
using Dundas.Charting.WinControl;
   ...  
    
Chart1.ChartAreas["Default"].AxisX.Minimum = 0;
Chart1.ChartAreas["Default"].AxisX.Maximum = 100;
Chart1.ChartAreas["Default"].AxisX.Interval = 20;
Chart1.ChartAreas["Default"].AxisX.IntervalOffset = 10;


Figure 1: A chart displaying intervals, and interval offsets.

 

Example

This example demonstrates how to display the major grid lines, major tick marks, and labels on Mondays. We assume that a series named "Series1" has been populated with data at design-time, and that its Interval property is defined as one week. To accomplish all of this, we set the IntervalOffset for these chart elements to be 1, and the IntervalOffsetType to be in Days.

Visual Basic Copy Code
Imports Dundas.Charting.WinControl
   ...
   
' Set the interval properties for the axis.
Chart1.ChartAreas("Default").AxisX.Interval = 1
Chart1.ChartAreas("Default").AxisX.IntervalType = DateTimeIntervalType.Weeks
Chart1.ChartAreas("Default").AxisX.IntervalOffset = 1
Chart1.ChartAreas("Default").AxisX.IntervalOffsetType = DateTimeIntervalType.Days

' Set the X value type of the displayed series to DateTime.
Chart1.Series("Series1").XValueType = ChartValueTypes.DateTime

C# Copy Code
using Dundas.Charting.WinControl;
   ...
   
// Set the interval properties for the axis.
Chart1.ChartAreas["Default"].AxisX.Interval = 1;
Chart1.ChartAreas["Default"].AxisX.IntervalType = DateTimeIntervalType.Weeks;
Chart1.ChartAreas["Default"].AxisX.IntervalOffset = 1;
Chart1.ChartAreas["Default"].AxisX.IntervalOffsetType = DateTimeIntervalType.Days;

// Set the X value type of the displayed series to DateTime.
Chart1.Series["Series1"].XValueType = ChartValueTypes.DateTime;

See Also

©2009. All Rights Reserved.