| `bounds` | `string` | `'data'` | Determines the scale bounds. [more...](#scale-bounds)
| `ticks.source` | `string` | `'auto'` | How ticks are generated. [more...](#ticks-source)
| `time.displayFormats` | `object` | | Sets how different time units are displayed. [more...](#display-formats)
-| `time.isoWeekday` | `boolean` | `false` | If true and the unit is set to 'week', then the first day of the week will be Monday. Otherwise, it will be Sunday.
+| `time.isoWeekday` | `boolean`\|`number` | `false` | If `boolean` and true and the unit is set to 'week', then the first day of the week will be Monday. Otherwise, it will be Sunday. If `number`, the index of the first day of the week (0 - Sunday, 6 - Saturday)
| `time.parser` | `string`\|`function` | | Custom parser for dates. [more...](#parser)
| `time.round` | `string` | `false` | If defined, dates will be rounded to the start of this unit. See [Time Units](#time-units) below for the allowed units.
| `time.tooltipFormat` | `string` | | The format string to use for the tooltip.
import adapters from '../core/core.adapters';
import {isFinite, isNullOrUndef, mergeIf, valueOrDefault} from '../helpers/helpers.core';
-import {toRadians} from '../helpers/helpers.math';
+import {toRadians, isNumber} from '../helpers/helpers.math';
import Scale from '../core/core.scale';
import {_arrayUnique, _filterBetween, _lookup} from '../helpers/helpers.collection';
}
if (round) {
- value = round === 'week' && isoWeekday
+ value = round === 'week' && (isNumber(isoWeekday) || isoWeekday === true)
? scale._adapter.startOf(value, 'isoWeek', isoWeekday)
: scale._adapter.startOf(value, round);
}
const minor = timeOpts.unit || determineUnitForAutoTicks(timeOpts.minUnit, min, max, me._getLabelCapacity(min));
const stepSize = valueOrDefault(timeOpts.stepSize, 1);
const weekday = minor === 'week' ? timeOpts.isoWeekday : false;
+ const hasWeekday = isNumber(weekday) || weekday === true;
const ticks = {};
let first = min;
let time;
// For 'week' unit, handle the first day of week option
- if (weekday) {
+ if (hasWeekday) {
first = +adapter.startOf(first, 'isoWeek', weekday);
}
// Align first ticks on unit
- first = +adapter.startOf(first, weekday ? 'day' : minor);
+ first = +adapter.startOf(first, hasWeekday ? 'day' : minor);
// Prevent browser from freezing in case user options request millions of milliseconds
if (adapter.diff(max, min, minor) > 100000 * stepSize) {
*/
round: false | TimeUnit;
/**
- * If true and the unit is set to 'week', then the first day of the week will be Monday. Otherwise, it will be Sunday.
+ * If boolean and true and the unit is set to 'week', then the first day of the week will be Monday. Otherwise, it will be Sunday.
+ * If `number`, the index of the first day of the week (0 - Sunday, 6 - Saturday).
* @default false
*/
- isoWeekday: false | string;
+ isoWeekday: false | number;
/**
* Sets how different time units are displayed.
* @see https://www.chartjs.org/docs/next/axes/cartesian/time#display-formats