Table of Contents

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 ITimeUnit

The time unit to use for major ticks

intervalsPerTick int

The number of Interval units between major ticks

minorInterval ITimeUnit

The time unit to use for minor ticks. If null, no minor ticks are generated.

minorIntervalsPerTick int

The 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

Func<DateTime, DateTime>

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

ITimeUnit

IntervalsPerTick

The number of Interval units between major ticks (e.g. major ticks every 7 Days)

public int IntervalsPerTick { get; set; }

Property Value

int

LabelFormatter

If assigned, this function will be used to create tick labels

public Func<DateTime, string>? LabelFormatter { get; set; }

Property Value

Func<DateTime, string>

MaxTickCount

Do not generate more than this number of ticks

public int MaxTickCount { get; set; }

Property Value

int

MinorInterval

The time unit to use for minor ticks. If null, no minor ticks are generated.

public ITimeUnit? MinorInterval { get; set; }

Property Value

ITimeUnit

MinorIntervalsPerTick

The number of MinorInterval units between minor ticks.

public int MinorIntervalsPerTick { get; set; }

Property Value

int

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

IEnumerable<double>

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 CoordinateRange
edge Edge
size PixelLength
paint SKPaint
labelStyle LabelStyle