MCPcopy
hub / github.com/chartjs/Chart.js / _addGrace

Function _addGrace

src/helpers/helpers.options.ts:186–194  ·  view source on GitHub ↗
(minmax: { min: number; max: number; }, grace: number | string, beginAtZero: boolean)

Source from the content-addressed store, hash-verified

184 * @private
185 */
186export function _addGrace(minmax: { min: number; max: number; }, grace: number | string, beginAtZero: boolean) {
187 const {min, max} = minmax;
188 const change = toDimension(grace, (max - min) / 2);
189 const keepZero = (value: number, add: number) => beginAtZero && value === 0 ? 0 : value + add;
190 return {
191 min: keepZero(min, -Math.abs(change)),
192 max: keepZero(max, change)
193 };
194}
195
196/**
197 * Create a context inheriting parentContext

Callers 1

updateMethod · 0.85

Calls 2

toDimensionFunction · 0.85
keepZeroFunction · 0.85

Tested by

no test coverage detected