Use ticks.steSize instead of time.stepSize on time and timeseries scales (#10653)

This commit is contained in:
stockiNail
2022-09-10 17:46:26 +02:00
committed by GitHub
parent 83a41c2e0c
commit 9871aaa262
5 changed files with 4 additions and 8 deletions

View File

@@ -38,7 +38,6 @@ Namespace: `options.scales[scaleId]`
| `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.
| `time.unit` | `string` | `false` | If defined, will force the unit to be a certain type. See [Time Units](#time-units) section below for details.
| `time.stepSize` | `number` | `1` | The number of units between grid lines.
| `time.minUnit` | `string` | `'millisecond'` | The minimum display format to be used for a time unit.
!!!include(axes/cartesian/_common.md)!!!

View File

@@ -27,6 +27,7 @@ A number of changes were made to the configuration options passed to the `Chart`
* Linear scales now add and subtracts `5%` of the max value to the range if the min and max are the same instead of `1`.
* If the tooltip callback returns `undefined`, then the default callback will be used.
* `maintainAspectRatio` respects container height.
* Time and timeseries scales use `ticks.stepSize` instead of `time.stepSize`, which has been removed.
#### Type changes
* The order of the `ChartMeta` parameters have been changed from `<Element, DatasetElement, Type>` to `<Type, Element, DatasetElement>`.

View File

@@ -455,7 +455,7 @@ export default class TimeScale extends Scale {
const timeOpts = options.time;
// @ts-ignore
const minor = timeOpts.unit || determineUnitForAutoTicks(timeOpts.minUnit, min, max, this._getLabelCapacity(min));
const stepSize = valueOrDefault(timeOpts.stepSize, 1);
const stepSize = valueOrDefault(options.ticks.stepSize, 1);
const weekday = minor === 'week' ? timeOpts.isoWeekday : false;
const hasWeekday = isNumber(weekday) || weekday === true;
const ticks = {};

View File

@@ -12,6 +12,8 @@ module.exports = {
bounds: 'ticks',
time: {
unit: 'hour',
},
ticks: {
stepSize: 2
}
},

6
types/index.d.ts vendored
View File

@@ -3238,12 +3238,6 @@ export type TimeScaleOptions = Omit<CartesianScaleOptions, 'min' | 'max'> & {
* @default false
*/
unit: false | TimeUnit;
/**
* The number of units between grid lines.
* @default 1
*/
stepSize: number;
/**
* The minimum display format to be used for a time unit.
* @default 'millisecond'