@hpcc-js/timeline 3.3.2 → 3.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,126 +1,126 @@
1
- import { timeFormat as d3TimeFormat, timeParse as d3TimeParse } from "d3-time-format";
2
- import { ReactAxisGantt } from "./ReactAxisGantt.ts";
3
-
4
- export class ReactTimeline extends ReactAxisGantt {
5
-
6
- protected _axisLabelFormatter;//TODO: add a type to this? d3 time formatting function type?
7
-
8
- constructor() {
9
- super();
10
- this._drawStartPos = "origin";
11
- this._topAxis.type("time");
12
- this._bottomAxis.type("time");
13
-
14
- this.tooltipHTML((d: any) => {
15
- const parser = d3TimeParse("%Q");
16
- const startTime = parser(d[1]);
17
- const endTime = parser(d[2]);
18
-
19
- const formatter = d3TimeFormat(this.tooltipTimeFormat());
20
- return `<div style="text-align:center;">${d[0]}<br/><br/>${formatter(startTime)} -&gt; ${formatter(endTime)}</div>`;
21
- });
22
- }
23
-
24
- update(domNode, element) {
25
- super.update(domNode, element);
26
-
27
- if (this.timePattern_exists()) {
28
-
29
- let minTimestamp = Infinity;
30
- let maxTimestamp = -Infinity;
31
- let lowDateStr = "";
32
- let highDateStr = "";
33
- this.data().map(n => {
34
- const start = new Date(n[1]).getTime();
35
- const end = new Date(n[2]).getTime();
36
- if (minTimestamp > start) {
37
- minTimestamp = start;
38
- lowDateStr = "" + n[1];
39
- }
40
- if (maxTimestamp < end) {
41
- maxTimestamp = end;
42
- highDateStr = "" + n[2];
43
- }
44
- });
45
-
46
- const axisTickFormat = this._axisLabelFormatter
47
- ? this._axisLabelFormatter
48
- : (this.tickFormat_exists && this.tickFormat_exists() ? this.tickFormat() : undefined);
49
-
50
- this._topAxis
51
- .type("time")
52
- .timePattern(this.timePattern())
53
- .overlapMode("none")
54
- .low(lowDateStr)
55
- .high(highDateStr)
56
- ;
57
- this._bottomAxis
58
- .type("time")
59
- .timePattern(this.timePattern())
60
- .overlapMode("none")
61
- .low(lowDateStr)
62
- .high(highDateStr)
63
- ;
64
-
65
- if (axisTickFormat) {
66
- this._topAxis.tickFormat(axisTickFormat);
67
- this._bottomAxis.tickFormat(axisTickFormat);
68
- } else {
69
- this._topAxis.tickFormat_reset();
70
- this._bottomAxis.tickFormat_reset();
71
- }
72
- this._gantt._minStart = minTimestamp;
73
- this._gantt._maxEnd = maxTimestamp;
74
- }
75
- }
76
-
77
- tooltipHTML(callback) {
78
- this._tooltipHTML = callback;
79
- this.tooltip().tooltipHTML(this._tooltipHTML);
80
- return this;
81
- }
82
-
83
- parseAxisValue(v) {
84
- const parseTime = d3TimeParse("%Q");
85
- const parsedTime = parseTime(v);
86
-
87
- const formatTime = d3TimeFormat(this.timePattern());
88
- return formatTime(parsedTime);
89
- }
90
-
91
- onzoom(transform) {
92
-
93
- const w = this.width();
94
- const low = this._gantt._minStart;
95
- const high = this._gantt._maxEnd;
96
- const range = high - low;
97
- const wpp = range / w;
98
- const nextLow = Math.floor(low - (wpp * (transform.x / transform.k)));
99
- const nextHigh = Math.ceil((range / transform.k) + nextLow);
100
-
101
- this._topAxis
102
- .low(this.parseAxisValue(nextLow))
103
- .high(this.parseAxisValue(nextHigh))
104
- .render()
105
- ;
106
- this._bottomAxis
107
- .low(this.parseAxisValue(nextLow))
108
- .high(this.parseAxisValue(nextHigh))
109
- .render()
110
- ;
111
- }
112
- }
113
- ReactTimeline.prototype._class += " timeline_ReactTimeline";
114
-
115
- export interface ReactTimeline {
116
- _tooltipHTML(_): string;
117
-
118
- timePattern(): string;
119
- timePattern(_: string): this;
120
- timePattern_exists(): boolean;
121
- tooltipTimeFormat(): string;
122
- tooltipTimeFormat(_: string): this;
123
- }
124
- ReactTimeline.prototype.publish("timePattern", "%Y-%m-%d", "string", "Time pattern used for parsing datetime strings on each data row", null, { optional: true });
125
- ReactTimeline.prototype.publish("tooltipTimeFormat", "%Y-%m-%d", "string", "Time format used in the default html tooltip");
126
-
1
+ import { timeFormat as d3TimeFormat, timeParse as d3TimeParse } from "d3-time-format";
2
+ import { ReactAxisGantt } from "./ReactAxisGantt.ts";
3
+
4
+ export class ReactTimeline extends ReactAxisGantt {
5
+
6
+ protected _axisLabelFormatter;//TODO: add a type to this? d3 time formatting function type?
7
+
8
+ constructor() {
9
+ super();
10
+ this._drawStartPos = "origin";
11
+ this._topAxis.type("time");
12
+ this._bottomAxis.type("time");
13
+
14
+ this.tooltipHTML((d: any) => {
15
+ const parser = d3TimeParse("%Q");
16
+ const startTime = parser(d[1]);
17
+ const endTime = parser(d[2]);
18
+
19
+ const formatter = d3TimeFormat(this.tooltipTimeFormat());
20
+ return `<div style="text-align:center;">${d[0]}<br/><br/>${formatter(startTime)} -&gt; ${formatter(endTime)}</div>`;
21
+ });
22
+ }
23
+
24
+ update(domNode, element) {
25
+ super.update(domNode, element);
26
+
27
+ if (this.timePattern_exists()) {
28
+
29
+ let minTimestamp = Infinity;
30
+ let maxTimestamp = -Infinity;
31
+ let lowDateStr = "";
32
+ let highDateStr = "";
33
+ this.data().map(n => {
34
+ const start = new Date(n[1]).getTime();
35
+ const end = new Date(n[2]).getTime();
36
+ if (minTimestamp > start) {
37
+ minTimestamp = start;
38
+ lowDateStr = "" + n[1];
39
+ }
40
+ if (maxTimestamp < end) {
41
+ maxTimestamp = end;
42
+ highDateStr = "" + n[2];
43
+ }
44
+ });
45
+
46
+ const axisTickFormat = this._axisLabelFormatter
47
+ ? this._axisLabelFormatter
48
+ : (this.tickFormat_exists && this.tickFormat_exists() ? this.tickFormat() : undefined);
49
+
50
+ this._topAxis
51
+ .type("time")
52
+ .timePattern(this.timePattern())
53
+ .overlapMode("none")
54
+ .low(lowDateStr)
55
+ .high(highDateStr)
56
+ ;
57
+ this._bottomAxis
58
+ .type("time")
59
+ .timePattern(this.timePattern())
60
+ .overlapMode("none")
61
+ .low(lowDateStr)
62
+ .high(highDateStr)
63
+ ;
64
+
65
+ if (axisTickFormat) {
66
+ this._topAxis.tickFormat(axisTickFormat);
67
+ this._bottomAxis.tickFormat(axisTickFormat);
68
+ } else {
69
+ this._topAxis.tickFormat_reset();
70
+ this._bottomAxis.tickFormat_reset();
71
+ }
72
+ this._gantt._minStart = minTimestamp;
73
+ this._gantt._maxEnd = maxTimestamp;
74
+ }
75
+ }
76
+
77
+ tooltipHTML(callback) {
78
+ this._tooltipHTML = callback;
79
+ this.tooltip().tooltipHTML(this._tooltipHTML);
80
+ return this;
81
+ }
82
+
83
+ parseAxisValue(v) {
84
+ const parseTime = d3TimeParse("%Q");
85
+ const parsedTime = parseTime(v);
86
+
87
+ const formatTime = d3TimeFormat(this.timePattern());
88
+ return formatTime(parsedTime);
89
+ }
90
+
91
+ onzoom(transform) {
92
+
93
+ const w = this.width();
94
+ const low = this._gantt._minStart;
95
+ const high = this._gantt._maxEnd;
96
+ const range = high - low;
97
+ const wpp = range / w;
98
+ const nextLow = Math.floor(low - (wpp * (transform.x / transform.k)));
99
+ const nextHigh = Math.ceil((range / transform.k) + nextLow);
100
+
101
+ this._topAxis
102
+ .low(this.parseAxisValue(nextLow))
103
+ .high(this.parseAxisValue(nextHigh))
104
+ .render()
105
+ ;
106
+ this._bottomAxis
107
+ .low(this.parseAxisValue(nextLow))
108
+ .high(this.parseAxisValue(nextHigh))
109
+ .render()
110
+ ;
111
+ }
112
+ }
113
+ ReactTimeline.prototype._class += " timeline_ReactTimeline";
114
+
115
+ export interface ReactTimeline {
116
+ _tooltipHTML(_): string;
117
+
118
+ timePattern(): string;
119
+ timePattern(_: string): this;
120
+ timePattern_exists(): boolean;
121
+ tooltipTimeFormat(): string;
122
+ tooltipTimeFormat(_: string): this;
123
+ }
124
+ ReactTimeline.prototype.publish("timePattern", "%Y-%m-%d", "string", "Time pattern used for parsing datetime strings on each data row", null, { optional: true });
125
+ ReactTimeline.prototype.publish("tooltipTimeFormat", "%Y-%m-%d", "string", "Time format used in the default html tooltip");
126
+
@@ -1,141 +1,141 @@
1
- import { timeFormat as d3TimeFormat, timeParse as d3TimeParse } from "d3-time-format";
2
- import { ReactAxisGanttSeries } from "./ReactAxisGanttSeries.ts";
3
-
4
- const parseTime = d3TimeParse("%Q");
5
- export class ReactTimelineSeries extends ReactAxisGanttSeries {
6
-
7
- protected _axisLabelFormatter;//TODO: add a type to this? d3 time formatting function type?
8
-
9
- constructor() {
10
- super();
11
- this._topAxis.type("time");
12
- this._bottomAxis.type("time");
13
-
14
- this.tooltipHTML((d: any) => {
15
- const startTime = parseTime(d[1]);
16
- const endTime = parseTime(d[2]);
17
-
18
- const formatter = d3TimeFormat(this.tooltipTimeFormat());
19
- return `<div style="text-align:center;">${d[0]}<br/><br/>${formatter(startTime)} -&gt; ${formatter(endTime)}</div>`;
20
- });
21
- }
22
-
23
- update(domNode, element) {
24
- super.update(domNode, element);
25
-
26
- if (this.timePattern_exists()) {
27
-
28
- let minTimestamp = Infinity;
29
- let maxTimestamp = -Infinity;
30
- let lowDateStr = "";
31
- let highDateStr = "";
32
- this.data().forEach(n => {
33
- const start = new Date(n[1]).getTime();
34
- const end = new Date(n[2]).getTime();
35
- if (minTimestamp > start) {
36
- minTimestamp = start;
37
- lowDateStr = "" + n[1];
38
- }
39
- if (maxTimestamp < end) {
40
- maxTimestamp = end;
41
- highDateStr = "" + n[2];
42
- }
43
- });
44
-
45
- const axisTickFormat = this._axisLabelFormatter
46
- ? this._axisLabelFormatter
47
- : (this.tickFormat_exists && this.tickFormat_exists() ? this.tickFormat() : undefined);
48
-
49
- this._topAxis
50
- .type("time")
51
- .timePattern(this.timePattern())
52
- .overlapMode("none")
53
- .low(lowDateStr)
54
- .high(highDateStr)
55
- ;
56
- this._bottomAxis
57
- .type("time")
58
- .timePattern(this.timePattern())
59
- .overlapMode("none")
60
- .low(lowDateStr)
61
- .high(highDateStr)
62
- ;
63
-
64
- if (axisTickFormat) {
65
- this._topAxis.tickFormat(axisTickFormat);
66
- this._bottomAxis.tickFormat(axisTickFormat);
67
- } else {
68
- this._topAxis.tickFormat_reset();
69
- this._bottomAxis.tickFormat_reset();
70
- }
71
- this._gantt._minStart = minTimestamp;
72
- this._gantt._maxEnd = maxTimestamp;
73
- }
74
- }
75
-
76
- tickFormatFunc(fn: (d: any) => string): this;
77
- tickFormatFunc(): ((d: any) => string) | undefined;
78
- tickFormatFunc(fn?: (d: any) => string): this | ((d: any) => string) | undefined {
79
- if (!arguments.length) {
80
- return this._axisLabelFormatter;
81
- }
82
- this._axisLabelFormatter = fn;
83
-
84
- // Delegate to underlying Axis instances using the proper method
85
- this._topAxis.tickFormatFunc(fn);
86
- this._bottomAxis.tickFormatFunc(fn);
87
-
88
- return this;
89
- }
90
-
91
- tooltipHTML(callback) {
92
- this._tooltipHTML = callback;
93
- this.tooltip().tooltipHTML(this._tooltipHTML);
94
- return this;
95
- }
96
-
97
- parseAxisValue(v) {
98
- const parsedTime = parseTime(v);
99
-
100
- const formatTime = d3TimeFormat(this.timePattern());
101
- return formatTime(parsedTime);
102
- }
103
-
104
- onzoom(transform) {
105
-
106
- const w = this.width();
107
- const low = this._gantt._minStart;
108
- const high = this._gantt._maxEnd;
109
- const range = high - low;
110
- const wpp = range / w;
111
- const nextLow = Math.floor(low - (wpp * (transform.x / transform.k)));
112
- const nextHigh = Math.ceil((range / transform.k) + nextLow);
113
-
114
- this._topAxis
115
- .low(this.parseAxisValue(nextLow))
116
- .high(this.parseAxisValue(nextHigh))
117
- .render()
118
- ;
119
- this._bottomAxis
120
- .low(this.parseAxisValue(nextLow))
121
- .high(this.parseAxisValue(nextHigh))
122
- .render()
123
- ;
124
- }
125
-
126
- _tooltipHTML: (_) => string;
127
- }
128
- ReactTimelineSeries.prototype._class += " timeline_ReactTimelineSeries";
129
-
130
- export interface ReactTimelineSeries {
131
- timePattern(): string;
132
- timePattern(_: string): this;
133
- timePattern_exists(): boolean;
134
- tooltipTimeFormat(): string;
135
- tooltipTimeFormat(_: string): this;
136
- tickFormatFunc(fn: (d: any) => string): this;
137
- tickFormatFunc(): ((d: any) => string) | undefined;
138
- }
139
- ReactTimelineSeries.prototype.publish("timePattern", "%Y-%m-%d", "string", "Time pattern used for parsing datetime strings on each data row", null, { optional: true });
140
- ReactTimelineSeries.prototype.publish("tooltipTimeFormat", "%Y-%m-%d", "string", "Time format used in the default html tooltip");
141
-
1
+ import { timeFormat as d3TimeFormat, timeParse as d3TimeParse } from "d3-time-format";
2
+ import { ReactAxisGanttSeries } from "./ReactAxisGanttSeries.ts";
3
+
4
+ const parseTime = d3TimeParse("%Q");
5
+ export class ReactTimelineSeries extends ReactAxisGanttSeries {
6
+
7
+ protected _axisLabelFormatter;//TODO: add a type to this? d3 time formatting function type?
8
+
9
+ constructor() {
10
+ super();
11
+ this._topAxis.type("time");
12
+ this._bottomAxis.type("time");
13
+
14
+ this.tooltipHTML((d: any) => {
15
+ const startTime = parseTime(d[1]);
16
+ const endTime = parseTime(d[2]);
17
+
18
+ const formatter = d3TimeFormat(this.tooltipTimeFormat());
19
+ return `<div style="text-align:center;">${d[0]}<br/><br/>${formatter(startTime)} -&gt; ${formatter(endTime)}</div>`;
20
+ });
21
+ }
22
+
23
+ update(domNode, element) {
24
+ super.update(domNode, element);
25
+
26
+ if (this.timePattern_exists()) {
27
+
28
+ let minTimestamp = Infinity;
29
+ let maxTimestamp = -Infinity;
30
+ let lowDateStr = "";
31
+ let highDateStr = "";
32
+ this.data().forEach(n => {
33
+ const start = new Date(n[1]).getTime();
34
+ const end = new Date(n[2]).getTime();
35
+ if (minTimestamp > start) {
36
+ minTimestamp = start;
37
+ lowDateStr = "" + n[1];
38
+ }
39
+ if (maxTimestamp < end) {
40
+ maxTimestamp = end;
41
+ highDateStr = "" + n[2];
42
+ }
43
+ });
44
+
45
+ const axisTickFormat = this._axisLabelFormatter
46
+ ? this._axisLabelFormatter
47
+ : (this.tickFormat_exists && this.tickFormat_exists() ? this.tickFormat() : undefined);
48
+
49
+ this._topAxis
50
+ .type("time")
51
+ .timePattern(this.timePattern())
52
+ .overlapMode("none")
53
+ .low(lowDateStr)
54
+ .high(highDateStr)
55
+ ;
56
+ this._bottomAxis
57
+ .type("time")
58
+ .timePattern(this.timePattern())
59
+ .overlapMode("none")
60
+ .low(lowDateStr)
61
+ .high(highDateStr)
62
+ ;
63
+
64
+ if (axisTickFormat) {
65
+ this._topAxis.tickFormat(axisTickFormat);
66
+ this._bottomAxis.tickFormat(axisTickFormat);
67
+ } else {
68
+ this._topAxis.tickFormat_reset();
69
+ this._bottomAxis.tickFormat_reset();
70
+ }
71
+ this._gantt._minStart = minTimestamp;
72
+ this._gantt._maxEnd = maxTimestamp;
73
+ }
74
+ }
75
+
76
+ tickFormatFunc(fn: (d: any) => string): this;
77
+ tickFormatFunc(): ((d: any) => string) | undefined;
78
+ tickFormatFunc(fn?: (d: any) => string): this | ((d: any) => string) | undefined {
79
+ if (!arguments.length) {
80
+ return this._axisLabelFormatter;
81
+ }
82
+ this._axisLabelFormatter = fn;
83
+
84
+ // Delegate to underlying Axis instances using the proper method
85
+ this._topAxis.tickFormatFunc(fn);
86
+ this._bottomAxis.tickFormatFunc(fn);
87
+
88
+ return this;
89
+ }
90
+
91
+ tooltipHTML(callback) {
92
+ this._tooltipHTML = callback;
93
+ this.tooltip().tooltipHTML(this._tooltipHTML);
94
+ return this;
95
+ }
96
+
97
+ parseAxisValue(v) {
98
+ const parsedTime = parseTime(v);
99
+
100
+ const formatTime = d3TimeFormat(this.timePattern());
101
+ return formatTime(parsedTime);
102
+ }
103
+
104
+ onzoom(transform) {
105
+
106
+ const w = this.width();
107
+ const low = this._gantt._minStart;
108
+ const high = this._gantt._maxEnd;
109
+ const range = high - low;
110
+ const wpp = range / w;
111
+ const nextLow = Math.floor(low - (wpp * (transform.x / transform.k)));
112
+ const nextHigh = Math.ceil((range / transform.k) + nextLow);
113
+
114
+ this._topAxis
115
+ .low(this.parseAxisValue(nextLow))
116
+ .high(this.parseAxisValue(nextHigh))
117
+ .render()
118
+ ;
119
+ this._bottomAxis
120
+ .low(this.parseAxisValue(nextLow))
121
+ .high(this.parseAxisValue(nextHigh))
122
+ .render()
123
+ ;
124
+ }
125
+
126
+ _tooltipHTML: (_) => string;
127
+ }
128
+ ReactTimelineSeries.prototype._class += " timeline_ReactTimelineSeries";
129
+
130
+ export interface ReactTimelineSeries {
131
+ timePattern(): string;
132
+ timePattern(_: string): this;
133
+ timePattern_exists(): boolean;
134
+ tooltipTimeFormat(): string;
135
+ tooltipTimeFormat(_: string): this;
136
+ tickFormatFunc(fn: (d: any) => string): this;
137
+ tickFormatFunc(): ((d: any) => string) | undefined;
138
+ }
139
+ ReactTimelineSeries.prototype.publish("timePattern", "%Y-%m-%d", "string", "Time pattern used for parsing datetime strings on each data row", null, { optional: true });
140
+ ReactTimelineSeries.prototype.publish("tooltipTimeFormat", "%Y-%m-%d", "string", "Time format used in the default html tooltip");
141
+
@@ -1,3 +1,3 @@
1
- export const PKG_NAME = "__PACKAGE_NAME__";
2
- export const PKG_VERSION = "__PACKAGE_VERSION__";
3
- export const BUILD_VERSION = "__BUILD_VERSION__";
1
+ export const PKG_NAME = "__PACKAGE_NAME__";
2
+ export const PKG_VERSION = "__PACKAGE_VERSION__";
3
+ export const BUILD_VERSION = "__BUILD_VERSION__";
package/src/index.ts CHANGED
@@ -1,7 +1,7 @@
1
- export * from "./__package__.ts";
2
- export * from "./MiniGantt.ts";
3
- export * from "./ReactGantt.ts";
4
- export * from "./ReactAxisGantt.ts";
5
- export * from "./ReactAxisGanttSeries.ts";
6
- export * from "./ReactTimeline.ts";
7
- export * from "./ReactTimelineSeries.ts";
1
+ export * from "./__package__.ts";
2
+ export * from "./MiniGantt.ts";
3
+ export * from "./ReactGantt.ts";
4
+ export * from "./ReactAxisGantt.ts";
5
+ export * from "./ReactAxisGanttSeries.ts";
6
+ export * from "./ReactTimeline.ts";
7
+ export * from "./ReactTimelineSeries.ts";