This section will describe the following:
- Scale Types
What the different axis scales offer.
Controlling numeric and time tick intervals.
- Scale Range
Controlling the axis scale start, end, and range.
- Scale Breaks
Using scale breaks.
- Scale Influentials
Allow axis markers and custom axis tick to influence axis scale ranges.
Axis scales dictate more than just the values on an axis. They also specify element behavior such as stacked, or FullStacked. The options for the Scale enumeration include:
Between numeric and time scales, .netCHARTING will automatically set the appropriate scale so it does not always need to be specified explicitly. Scales such as Stacked or FullStacked only apply to axes on which the element y values are plotted because these are the values that are stacked. For example with a combo chart, the Chart.YAxis would be the one to specify a stacked scale.
Other properties that control the scale include:
specifies the logarithmic base of intervals.
A '%' sign will be added to the end of tick labels and the axis maximum will snap to 100% if the plotted data's range falls between 50 and 100.
reverses the sequence of a scale.
Intervals come in two flavors, numeric, and time. The latter is more complicated so we’ll tackle numeric first.
Controlling the interval is a simple concept. You can specify a numeric interval using code such as:
Chart.YAxis.Interval = 5;
Chart.YAxis.Interval = 5
This will force an interval at every five numeric units. Other interval related properties include:
Specifies the minimum numeric interval.
TIP: This allows you to prevent the axis scale from using intervals that are smaller than a single unit of your data. For example a chart showing votes and the maximum number being 3 may show intervals at .5 which are not desired.
Specifies the maximum number of ticks to generate.
The basic time interval is controlled with the Axis.TimeInterval property
Axis.TimeInterval = TimeInterval.Week;
Axis.TimeInterval = TimeInterval.Week
Advanced time interval
A more complex time interval is also available and can be specified through the Axis.TimeIntervalAdvanced property.
Using the advanced time interval version allows you to specify an interval multiplier. For example we can have an interval every 4 days or 2 weeks etc.
Axis.TimeIntervalAdvanced.Multiplier = 2;
Axis.TimeIntervalAdvanced.Multiplier = 2
Custom time span
A completely custom time span can be used as a time interval.
Axis.TimeIntervalAdvanced.TimeSpan = new TimeSpan(10,5,3);
Axis.TimeIntervalAdvanced.TimeSpan = New TimeSpan(10,5,3)
Custom start time
An interval can also start at any given time. These times can be specified through the following properties:
The month of year at which this interval initially occurs. Value ranges from zero indicating January, to eleven, indicating December.
The day of the week at which this interval initially occurs. Value ranges from zero indicating Sunday, to six, indicating Saturday.
A DateTime object representing the time instant at which this interval initially occurs. The value of this DateTime structure can be specific down to the millisecond.
The scale’s numeric, time, and category axis boundaries can be specified using the Axis.ScaleRange property. New in version 5.0, the scale range can also represent a range on a category axis.
Chart.YAxis.ScaleRange.ValueHigh = 100;
Chart.YAxis.ScaleRange.ValueLow = 2;
Chart.YAxis.ScaleRange.ValueHigh = new DateTime(2000,12,1);
Chart.YAxis.ScaleRange.ValueLow = new DateTime(2000,1,1);
Chart.YAxis.ScaleRange.ValueHigh = 100
Chart.YAxis.ScaleRange.ValueLow = 2
Chart.YAxis.ScaleRange.ValueHigh = New DateTime(2000,12,1)
Chart.YAxis.ScaleRange.ValueLow = New DateTime(2000,1,1)
Providing a single high or low value without its counterpart is also permitted.
YAxis.ScaleRange.ValueLow = 2;
YAxis.ScaleRange.ValueLow = 2;
|Note: Numeric intervals start at zero, therefore, if the minimum value doesn’t land on an interval there may be a gap between the scale’s edge and the first axis tick.|
Category Axis Scale Ranges
New in version 5.0, the scale range can also represent a category axis range. It can achieved in two ways. The axis tick label text can be used to specify the range. The other way is to use a zero-based indexes to reference the axis ticks. For example, if there are 10 axis ticks they can be referenced using a numeric index of [0-9]. This code demonstrates the two methods.
// Using names. Chart.XAxis.ExtraTicks.Add(new AxisTick("Element 1", "Element 3", "Range")); // Using indexes. Chart.XAxis.ExtraTicks.Add(new AxisTick(0, 2, "Range"));
' Using names. Chart.XAxis.ExtraTicks.Add(New AxisTick("Element 1", "Element 3", "Range")) ' Using indexes. Chart.XAxis.ExtraTicks.Add(New AxisTick(0, 2, "Range"))
Time Scale Padding
Time scale ranges can be padded with an equal amount of time on either side of the plotted data to produce the final range. This is achieved using Axis.TimePadding.
Chart.XAxis.TimePadding = TimeSpan.FromDays(10);
Chart.XAxis.TimePadding = TimeSpan.FromDays(10)
Scale breaks are discontinuities in an axis' scale. They are useful in the following scenarios:
- When there is a large difference between low and high element values.
- When element value variations are much smaller than the scale range.
- When specific days of a week should be excluded in the scale, for example, weekends are not needed in financial charts. Scale breaks can work with a calendar pattern in this case.
For the first two cases, the chart engine can automatically generate a scale break by setting Axis.SmartScaleBreak to true.
Scale breaks are added manually like so:
Axis.ScaleBreaks.Add( new ScaleRange(0,50) );
//Or for time:
Axis.ScaleBreaks.Add( new ScaleRange(new DateTime(2000,1,1), new DateTime(2000,12,1) ) );
Axis.ScaleBreaks.Add( New ScaleRange(0,50) )
'Or for time:
Axis.ScaleBreaks.Add( New ScaleRange(New DateTime(2000,1,1), New DateTime(2000,12,1) ) )
Scale Break Styles
A number of options are available to achieve the scale break style your charts require. The style can be set with the ScaleBreakStyle enumeration at the axis level as shown below.
Chart.YAxis.ScaleBreakStyle = ScaleBreakStyle.ZigZag;
Chart.YAxis.ScaleBreakStyle = ScaleBreakStyle.ZigZag
Objects that inherit from ScaleRange, such as AxisMarker and AxisTicks are able to influence the axis’ scale range. For instance, a chart showing bandwidth usage over a period of time with an axis marker representing the bandwidth limit may have elements that will never reach or even come close to the limit marker’s value. Because of this, the limit marker will not be visible on the chart; however, if AxisMarker.IncludeInAxisScale is true, the marker will tell the axis scale range to encompass its value.
Objects that can influence axis scales are: