[]
Specifies the unit of time for a chart axis or data series.
Use this enum with date-based category axis settings such as BaseUnit, MajorUnitScale, and MinorUnitScale to control whether the axis is measured in days, months, or years.
public enum TimeUnit
Public Enum TimeUnit
worksheet.Range["A1:B4"].Value = new object[,] {
{"Date", "Sales"},
{new DateTime(2024, 1, 1), 100},
{new DateTime(2024, 2, 1), 120},
{new DateTime(2024, 3, 1), 140}
};
IShape shape = worksheet.Shapes.AddChart(ChartType.Line, 20, 20, 300, 200);
shape.Chart.SeriesCollection.Add(worksheet.Range["A1:B4"], RowCol.Columns, true, true);
IAxis axis = shape.Chart.Axes.Item(AxisType.Category);
axis.CategoryType = CategoryType.TimeScale;
axis.BaseUnit = TimeUnit.Months;
| Name | Description |
|---|---|
| Days | Specifies days. |
| Months | Specifies months. |
| Years | Specifies years. |