日本語
@eightkk/vue-weave / core / createWorkingTimeScale
Function: createWorkingTimeScale()
createWorkingTimeScale(
range,periods,pixelsPerUnit,nonWorkingRatio?):TimeScale
Defined in: src/core/workingTimeScale.ts:27
A piecewise-linear TimeScale that gives working time pixelsPerUnit pixels per time unit and non-working time pixelsPerUnit * nonWorkingRatio. Use it as the scale prop of GanttChart so working hours get more room.
periodsare half-open[start, end)working periods, asbuildWorkPeriodsreturns them. They are clipped torange, and they may be unsorted, overlapping or touching: they are sorted and united. Periods outside the range are ignored. Endpoints must be finite with positive length (RangeErrorotherwise).nonWorkingRatiois a fraction in(0, 1], default 0.1. It cannot be 0: a collapsed interval would map many times to one pixel, sotoTimecould not inverttoX. A ratio of 1 gives a plain linear scale.- With no working period inside the range the whole range is non-working, so the scale is linear at
pixelsPerUnit * nonWorkingRatio. - Outside
rangethe scale extrapolates linearly with the slope of the nearest edge segment, sotoXandtoTimestay strictly increasing and mutually inverse for drags past either edge.toX(range.start)is 0 andtoX(range.end)iswidth.
Both mappings binary-search precomputed breakpoints, so a call costs O(log n) for n periods. The round trip is exact at segment boundaries and within floating-point rounding elsewhere. Changing the ratio or pixelsPerUnit changes only x positions, never times. The scale does not depend on text direction; GanttChart positions from the inline start edge in right-to-left charts.
Parameters
range
periods
readonly TimeRange[]
pixelsPerUnit
number
nonWorkingRatio?
number = defaultNonWorkingRatio