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

Function ticksFromTimestamps

src/scales/scale.time.js:177–197  ·  view source on GitHub ↗

* @param {TimeScale} scale * @param {number[]} values * @param {Unit|undefined} [majorUnit] * @return {object[]}

(scale, values, majorUnit)

Source from the content-addressed store, hash-verified

175 * @return {object[]}
176 */
177function ticksFromTimestamps(scale, values, majorUnit) {
178 const ticks = [];
179 /** @type {Object<number,object>} */
180 const map = {};
181 const ilen = values.length;
182 let i, value;
183
184 for (i = 0; i < ilen; ++i) {
185 value = values[i];
186 map[value] = i;
187
188 ticks.push({
189 value,
190 major: false
191 });
192 }
193
194 // We set the major ticks separately from the above loop because calling startOf for every tick
195 // is expensive when there is a large number of ticks
196 return (ilen === 0 || !majorUnit) ? ticks : setMajorTicks(scale, ticks, map, majorUnit);
197}
198
199export default class TimeScale extends Scale {
200

Callers 2

buildTicksMethod · 0.85
_getLabelCapacityMethod · 0.85

Calls 1

setMajorTicksFunction · 0.85

Tested by

no test coverage detected