MCPcopy
hub / github.com/NUKnightLab/TimelineJS3 / constructor

Method constructor

src/js/timenav/TimeScale.js:28–61  ·  view source on GitHub ↗
(timeline_config, options)

Source from the content-addressed store, hash-verified

26export class TimeScale {
27
28 constructor(timeline_config, options) {
29
30 var slides = timeline_config.events;
31 this._scale = timeline_config.scale;
32
33 options = mergeData({ // establish defaults
34 display_width: 500,
35 screen_multiplier: 3,
36 max_rows: null
37 }, options);
38
39 this._display_width = options.display_width;
40 this._screen_multiplier = options.screen_multiplier;
41 this._pixel_width = this._screen_multiplier * this._display_width;
42
43 this._group_labels = undefined;
44 this._positions = [];
45 this._pixels_per_milli = 0;
46
47 this._earliest = timeline_config.getEarliestDate().getTime();
48 this._latest = timeline_config.getLatestDate().getTime();
49 this._span_in_millis = this._latest - this._earliest;
50 if (this._span_in_millis <= 0) {
51 this._span_in_millis = this._computeDefaultSpan(timeline_config);
52 }
53 this._average = (this._span_in_millis) / slides.length;
54
55 this._pixels_per_milli = this.getPixelWidth() / this._span_in_millis;
56
57 this._axis_helper = getBestHelper(this);
58
59 this._scaled_padding = (1 / this.getPixelsPerTick()) * (this._display_width / 2)
60 this._computePositionInfo(slides, options.max_rows);
61 }
62
63 _computeDefaultSpan(timeline_config) {
64 // this gets called when all events are at the same instant,

Callers

nothing calls this directly

Calls 9

_computeDefaultSpanMethod · 0.95
getPixelWidthMethod · 0.95
getPixelsPerTickMethod · 0.95
_computePositionInfoMethod · 0.95
mergeDataFunction · 0.90
getBestHelperFunction · 0.90
getEarliestDateMethod · 0.80
getLatestDateMethod · 0.80
getTimeMethod · 0.45

Tested by

no test coverage detected