Class DateTimeFixedInterval
- Namespace
- ScottPlot.TickGenerators
- Assembly
- ScottPlot.dll
public class DateTimeFixedInterval : IDateTimeTickGenerator, ITickGenerator
- Inheritance
-
DateTimeFixedInterval
- Implements
- Inherited Members
- Extension Methods
Constructors
DateTimeFixedInterval(ITimeUnit, int, ITimeUnit?, int, Func<DateTime, DateTime>?)
Creates a new DateTimeFixedInterval generator.
public DateTimeFixedInterval(ITimeUnit interval, int intervalsPerTick = 1, ITimeUnit? minorInterval = null, int minorIntervalsPerTick = 1, Func<DateTime, DateTime>? getIntervalStartFunc = null)
Parameters
interval
ITimeUnitThe time unit to use for major ticks
intervalsPerTick
intThe number of Interval units between major ticks
minorInterval
ITimeUnitThe time unit to use for minor ticks. If null, no minor ticks are generated.
minorIntervalsPerTick
intThe number of MinorInterval units between minor ticks.
getIntervalStartFunc
Func<DateTime, DateTime>An optional function to override where the intervals for ticks start. The DateTime argument provided is the start range of the axis (i.e. Min).
Properties
GetIntervalStartFunc
An optional function to override where the intervals for ticks start. The DateTime argument provided is the start range of the axis (i.e. Min).
public Func<DateTime, DateTime>? GetIntervalStartFunc { get; set; }
Property Value
Examples
If the plot contains weekly data, and it is desired to have ticks on the 1st of each month:
dt => new DateTime(dt.Year, dt.Month, 1);
If the plot contains hourly data, and it is desired to have ticks every 6 hours at 00:00, 6:00, 12:00, etc, then set Interval to Hour, IntervalsPerTick to 6, and provide the function:
dt => new DateTime(dt.Year, dt.Month, dt.Day);
Remarks
If omitted, the ticks will start from Min. This may have undesirable effects when zooming and panning. If provided, the ticks will start from the returned DateTime.
Interval
The time unit to use for major ticks
public ITimeUnit Interval { get; set; }
Property Value
IntervalsPerTick
public int IntervalsPerTick { get; set; }
Property Value
LabelFormatter
If assigned, this function will be used to create tick labels
public Func<DateTime, string>? LabelFormatter { get; set; }
Property Value
MaxTickCount
Do not generate more than this number of ticks
public int MaxTickCount { get; set; }
Property Value
MinorInterval
The time unit to use for minor ticks. If null, no minor ticks are generated.
public ITimeUnit? MinorInterval { get; set; }
Property Value
MinorIntervalsPerTick
The number of MinorInterval units between minor ticks.
public int MinorIntervalsPerTick { get; set; }
Property Value
Ticks
Ticks to display the next time the axis is rendered. This array and its contents should not be modified directly. Call Regenerate() to update this array.
public Tick[] Ticks { get; set; }
Property Value
- Tick[]
Methods
ConvertToCoordinateSpace(IEnumerable<DateTime>)
public IEnumerable<double> ConvertToCoordinateSpace(IEnumerable<DateTime> dates)
Parameters
dates
IEnumerable<DateTime>
Returns
Regenerate(CoordinateRange, Edge, PixelLength, SKPaint, LabelStyle)
Generate ticks based on the current settings and store the result in Ticks
public void Regenerate(CoordinateRange range, Edge edge, PixelLength size, SKPaint paint, LabelStyle labelStyle)
Parameters
range
CoordinateRangeedge
Edgesize
PixelLengthpaint
SKPaintlabelStyle
LabelStyle