@hpcc-js/timeline 3.4.1 → 3.4.4

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,268 +1,268 @@
1
- import { min as d3Min, max as d3Max } from "d3-array";
2
- import { Axis } from "@hpcc-js/chart";
3
- import { Border2 } from "@hpcc-js/layout";
4
- import { React } from "@hpcc-js/react";
5
- import { ReactGantt } from "./ReactGantt.ts";
6
- import { IAxisGanttData } from "./ReactAxisGantt.ts";
7
-
8
- export class ReactAxisGanttSeries extends Border2 {
9
-
10
- protected _topAxis: Axis = new Axis("origin")
11
- .orientation("top")
12
- .type("linear")
13
- .shrinkToFit("none")
14
- .overlapMode("hide")
15
- .extend(0)
16
- .tickFormat("d")
17
- ;
18
- protected _gantt: ReactGantt = new ReactGantt("origin")
19
- .stroke("#000000")
20
- .fitHeightToContent(true)
21
- ;
22
- protected _bottomAxis: Axis = new Axis("origin")
23
- .orientation("bottom")
24
- .type("linear")
25
- .shrinkToFit("none")
26
- .overlapMode("hide")
27
- .extend(0)
28
- .tickFormat("d")
29
- ;
30
-
31
- protected _topAxisElement;
32
- protected _contentElement;
33
- protected _bottomAxisElement;
34
- protected _topRect;
35
- protected _contentRect;
36
- protected _bottomRect;
37
-
38
- constructor() {
39
- super();
40
- this.centerOverflowX_default("hidden");
41
- this.centerOverflowY_default("auto");
42
- }
43
-
44
- selection(_: any[]): this;
45
- selection(): any[];
46
- selection(_?: any[]): any[] | this {
47
- if (!arguments.length) return this._gantt.selection();
48
- this._gantt.selection(_);
49
- return this;
50
- }
51
-
52
- rangeRenderer(): React.FunctionComponent;
53
- rangeRenderer(_: React.FunctionComponent): this;
54
- rangeRenderer(_?: React.FunctionComponent): this | React.FunctionComponent {
55
- const ret = this._gantt.rangeRenderer.apply(this._gantt, arguments);
56
- if (!arguments.length) return ret;
57
- return this;
58
- }
59
-
60
- resizeWrappers() {
61
-
62
- const w = this.width();
63
- const h = this.height();
64
-
65
- const axisHeight = this.axisHeight(); //TODO: Dynamic scaling to allow for small resolutions?
66
- const contentHeight = (h - (axisHeight * 2));
67
-
68
- this.bottomHeight(axisHeight);
69
-
70
- this._topWA.resize({
71
- width: w,
72
- height: axisHeight
73
- });
74
- this._centerWA.resize({
75
- width: w,
76
- height: contentHeight
77
- });
78
- this._bottomWA.resize({
79
- width: w,
80
- height: axisHeight
81
- });
82
- this.top().render();
83
- this.bottom().render();
84
- this.center().render();
85
- }
86
-
87
- enter(domNode, element) {
88
- super.enter(domNode, element);
89
-
90
- this._gantt.click = (row, col, sel) => {
91
- this.click(row, col, sel);
92
- };
93
-
94
- this._gantt.dblclick = (row, col, sel) => {
95
- this.dblclick(row, col, sel);
96
- };
97
-
98
- this.top(this._topAxis);
99
- this.center(this._gantt);
100
- this.bottom(this._bottomAxis);
101
-
102
- this.resizeWrappers();
103
-
104
- this._gantt.zoomedHook = (transform) => {
105
- this.onzoom(transform);
106
- };
107
- }
108
-
109
- onzoom(transform) {
110
- const w = this.width();
111
- const low = this._gantt._minStart;
112
- const high = this._gantt._maxEnd;
113
- const range = high - low;
114
- const wpp = range / w;
115
- const nextLow = Math.floor(low - (wpp * (transform.x / transform.k)));
116
- const nextHigh = Math.ceil((range / transform.k) + nextLow);
117
-
118
- this._topAxis
119
- .fontFamily(this.axisFontFamily())
120
- .fontSize(this.axisFontSize())
121
- .tickLength(this.axisTickLength())
122
- .low(nextLow)
123
- .high(nextHigh)
124
- .lazyRender()
125
- ;
126
- this._bottomAxis
127
- .fontFamily(this.axisFontFamily())
128
- .fontSize(this.axisFontSize())
129
- .tickLength(this.axisTickLength())
130
- .low(nextLow)
131
- .high(nextHigh)
132
- .lazyRender()
133
- ;
134
- }
135
-
136
- update(domNode, element) {
137
- super.update(domNode, element);
138
- this._topAxis.tickFormat(this.tickFormat()).render();
139
- this._bottomAxis.tickFormat(this.tickFormat()).render();
140
- this._gantt.render();
141
- }
142
-
143
- columns(): string[];
144
- columns(_: string[]): this;
145
- columns(_?: string[]): this | string[] {
146
- const retVal = super.columns.apply(this, arguments);
147
- if (arguments.length > 0) {
148
- this._gantt.columns(_);
149
- }
150
- return retVal;
151
- }
152
-
153
- data(): IAxisGanttData[];
154
- data(_: IAxisGanttData[]): this;
155
- data(_?: IAxisGanttData[]): this | IAxisGanttData[] {
156
- const retVal = super.data.apply(this, arguments);
157
- if (arguments.length > 0) {
158
- const ganttData: any[] = this.data().map(n => {
159
- const ret = [...n];
160
- ret[1] = isNaN(n[1] as any) ? new Date(n[1]).getTime() : Number(n[1]);
161
- ret[2] = isNaN(n[2] as any) ? new Date(n[2]).getTime() : Number(n[2]);
162
- return ret;
163
- });
164
-
165
- this._gantt._minStart = d3Min(ganttData, n => n[1]);
166
- this._gantt._maxEnd = d3Max(ganttData, n => n[2]);
167
- this._gantt.data(ganttData);
168
- }
169
- return retVal;
170
- }
171
-
172
- resize(_size?: { width: number, height: number }) {
173
- const retVal = super.resize.apply(this, arguments);
174
-
175
- if (this._topAxisElement) {
176
- this.resizeWrappers();
177
- }
178
-
179
- return retVal;
180
- }
181
-
182
- click(row, col, sel) {
183
-
184
- }
185
-
186
- dblclick(row, col, sel) {
187
-
188
- }
189
-
190
- tooltip() {
191
- return this._gantt._tooltip;
192
- }
193
- }
194
- ReactAxisGanttSeries.prototype._class += " timeline_ReactAxisGanttSeries";
195
-
196
- export interface ReactAxisGanttSeries {
197
- tickFormat(): string;
198
- tickFormat(_: string): this;
199
- tickFormat_exists(): boolean;
200
- overlapTolerence(): number;
201
- overlapTolerence(_: number): this;
202
- smallestRangeWidth(): number;
203
- smallestRangeWidth(_: number): this;
204
- scaleMode(): boolean;
205
- scaleMode(_: boolean): this;
206
- fontSize(): number;
207
- fontSize(_: number): this;
208
- fontFamily(): string;
209
- fontFamily(_: string): this;
210
- strokeWidth(): number;
211
- strokeWidth(_: number): this;
212
- stroke(): string;
213
- stroke(_: string): this;
214
- cornerRadius(): number;
215
- cornerRadius(_: number): this;
216
- axisFontSize(): number;
217
- axisFontSize(_: number): this;
218
- axisFontFamily(): string;
219
- axisFontFamily(_: string): this;
220
- axisTickLength(): number;
221
- axisTickLength(_: number): this;
222
- axisHeight(): number;
223
- axisHeight(_: number): this;
224
- titleColumn(): string;
225
- titleColumn(_: string): this;
226
- startDateColumn(): string;
227
- startDateColumn(_: string): this;
228
- endDateColumn(): string;
229
- endDateColumn(_: string): this;
230
- iconColumn(): string;
231
- iconColumn(_: string): this;
232
- colorColumn(): string;
233
- colorColumn(_: string): this;
234
- seriesColumn(): string;
235
- seriesColumn(_: string): this;
236
- bucketColumn(): string;
237
- bucketColumn(_: string): this;
238
- maxZoom(): number;
239
- maxZoom(_: number): this;
240
- preserveZoom(): boolean;
241
- preserveZoom(_: boolean): this;
242
- }
243
- ReactAxisGanttSeries.prototype.publish("tickFormat", null, "string", "Format rule applied to axis tick labels", undefined, { optional: true });
244
- ReactAxisGanttSeries.prototype.publish("axisHeight", 22, "number", "Height of axes (pixels)");
245
- ReactAxisGanttSeries.prototype.publish("overlapTolerence", 2, "number", "overlapTolerence");
246
- ReactAxisGanttSeries.prototype.publish("smallestRangeWidth", 10, "number", "Width of the shortest range (pixels)");
247
- ReactAxisGanttSeries.prototype.publish("axisFontSize", null, "number", "Font size of axis tick labels");
248
- ReactAxisGanttSeries.prototype.publish("axisFontFamily", null, "string", "Font family of axis tick labels");
249
- ReactAxisGanttSeries.prototype.publish("axisTickLength", null, "number", "Length of axis ticks");
250
- ReactAxisGanttSeries.prototype.publishProxy("gutter", "_gantt");
251
- ReactAxisGanttSeries.prototype.publishProxy("renderMode", "_gantt");
252
- ReactAxisGanttSeries.prototype.publishProxy("strokeWidth", "_gantt");
253
- ReactAxisGanttSeries.prototype.publishProxy("fontSize", "_gantt");
254
- ReactAxisGanttSeries.prototype.publishProxy("fontFamily", "_gantt");
255
- ReactAxisGanttSeries.prototype.publishProxy("stroke", "_gantt");
256
- ReactAxisGanttSeries.prototype.publishProxy("cornerRadius", "_gantt");
257
- ReactAxisGanttSeries.prototype.publishProxy("titleColumn", "_gantt");
258
- ReactAxisGanttSeries.prototype.publishProxy("startDateColumn", "_gantt");
259
- ReactAxisGanttSeries.prototype.publishProxy("endDateColumn", "_gantt");
260
- ReactAxisGanttSeries.prototype.publishProxy("iconColumn", "_gantt");
261
- ReactAxisGanttSeries.prototype.publishProxy("colorColumn", "_gantt");
262
- ReactAxisGanttSeries.prototype.publishProxy("seriesColumn", "_gantt");
263
- ReactAxisGanttSeries.prototype.publishProxy("bucketColumn", "_gantt");
264
- ReactAxisGanttSeries.prototype.publishProxy("maxZoom", "_gantt");
265
- ReactAxisGanttSeries.prototype.publishProxy("preserveZoom", "_gantt");
266
- ReactAxisGanttSeries.prototype.publishProxy("evenSeriesBackground", "_gantt");
267
- ReactAxisGanttSeries.prototype.publishProxy("oddSeriesBackground", "_gantt");
268
- ReactAxisGanttSeries.prototype.publishProxy("bucketHeight", "_gantt");
1
+ import { min as d3Min, max as d3Max } from "d3-array";
2
+ import { Axis } from "@hpcc-js/chart";
3
+ import { Border2 } from "@hpcc-js/layout";
4
+ import { React } from "@hpcc-js/react";
5
+ import { ReactGantt } from "./ReactGantt.ts";
6
+ import { IAxisGanttData } from "./ReactAxisGantt.ts";
7
+
8
+ export class ReactAxisGanttSeries extends Border2 {
9
+
10
+ protected _topAxis: Axis = new Axis("origin")
11
+ .orientation("top")
12
+ .type("linear")
13
+ .shrinkToFit("none")
14
+ .overlapMode("hide")
15
+ .extend(0)
16
+ .tickFormat("d")
17
+ ;
18
+ protected _gantt: ReactGantt = new ReactGantt("origin")
19
+ .stroke("#000000")
20
+ .fitHeightToContent(true)
21
+ ;
22
+ protected _bottomAxis: Axis = new Axis("origin")
23
+ .orientation("bottom")
24
+ .type("linear")
25
+ .shrinkToFit("none")
26
+ .overlapMode("hide")
27
+ .extend(0)
28
+ .tickFormat("d")
29
+ ;
30
+
31
+ protected _topAxisElement;
32
+ protected _contentElement;
33
+ protected _bottomAxisElement;
34
+ protected _topRect;
35
+ protected _contentRect;
36
+ protected _bottomRect;
37
+
38
+ constructor() {
39
+ super();
40
+ this.centerOverflowX_default("hidden");
41
+ this.centerOverflowY_default("auto");
42
+ }
43
+
44
+ selection(_: any[]): this;
45
+ selection(): any[];
46
+ selection(_?: any[]): any[] | this {
47
+ if (!arguments.length) return this._gantt.selection();
48
+ this._gantt.selection(_);
49
+ return this;
50
+ }
51
+
52
+ rangeRenderer(): React.FunctionComponent;
53
+ rangeRenderer(_: React.FunctionComponent): this;
54
+ rangeRenderer(_?: React.FunctionComponent): this | React.FunctionComponent {
55
+ const ret = this._gantt.rangeRenderer.apply(this._gantt, arguments);
56
+ if (!arguments.length) return ret;
57
+ return this;
58
+ }
59
+
60
+ resizeWrappers() {
61
+
62
+ const w = this.width();
63
+ const h = this.height();
64
+
65
+ const axisHeight = this.axisHeight(); //TODO: Dynamic scaling to allow for small resolutions?
66
+ const contentHeight = (h - (axisHeight * 2));
67
+
68
+ this.bottomHeight(axisHeight);
69
+
70
+ this._topWA.resize({
71
+ width: w,
72
+ height: axisHeight
73
+ });
74
+ this._centerWA.resize({
75
+ width: w,
76
+ height: contentHeight
77
+ });
78
+ this._bottomWA.resize({
79
+ width: w,
80
+ height: axisHeight
81
+ });
82
+ this.top().render();
83
+ this.bottom().render();
84
+ this.center().render();
85
+ }
86
+
87
+ enter(domNode, element) {
88
+ super.enter(domNode, element);
89
+
90
+ this._gantt.click = (row, col, sel) => {
91
+ this.click(row, col, sel);
92
+ };
93
+
94
+ this._gantt.dblclick = (row, col, sel) => {
95
+ this.dblclick(row, col, sel);
96
+ };
97
+
98
+ this.top(this._topAxis);
99
+ this.center(this._gantt);
100
+ this.bottom(this._bottomAxis);
101
+
102
+ this.resizeWrappers();
103
+
104
+ this._gantt.zoomedHook = (transform) => {
105
+ this.onzoom(transform);
106
+ };
107
+ }
108
+
109
+ onzoom(transform) {
110
+ const w = this.width();
111
+ const low = this._gantt._minStart;
112
+ const high = this._gantt._maxEnd;
113
+ const range = high - low;
114
+ const wpp = range / w;
115
+ const nextLow = Math.floor(low - (wpp * (transform.x / transform.k)));
116
+ const nextHigh = Math.ceil((range / transform.k) + nextLow);
117
+
118
+ this._topAxis
119
+ .fontFamily(this.axisFontFamily())
120
+ .fontSize(this.axisFontSize())
121
+ .tickLength(this.axisTickLength())
122
+ .low(nextLow)
123
+ .high(nextHigh)
124
+ .lazyRender()
125
+ ;
126
+ this._bottomAxis
127
+ .fontFamily(this.axisFontFamily())
128
+ .fontSize(this.axisFontSize())
129
+ .tickLength(this.axisTickLength())
130
+ .low(nextLow)
131
+ .high(nextHigh)
132
+ .lazyRender()
133
+ ;
134
+ }
135
+
136
+ update(domNode, element) {
137
+ super.update(domNode, element);
138
+ this._topAxis.tickFormat(this.tickFormat()).render();
139
+ this._bottomAxis.tickFormat(this.tickFormat()).render();
140
+ this._gantt.render();
141
+ }
142
+
143
+ columns(): string[];
144
+ columns(_: string[]): this;
145
+ columns(_?: string[]): this | string[] {
146
+ const retVal = super.columns.apply(this, arguments);
147
+ if (arguments.length > 0) {
148
+ this._gantt.columns(_);
149
+ }
150
+ return retVal;
151
+ }
152
+
153
+ data(): IAxisGanttData[];
154
+ data(_: IAxisGanttData[]): this;
155
+ data(_?: IAxisGanttData[]): this | IAxisGanttData[] {
156
+ const retVal = super.data.apply(this, arguments);
157
+ if (arguments.length > 0) {
158
+ const ganttData: any[] = this.data().map(n => {
159
+ const ret = [...n];
160
+ ret[1] = isNaN(n[1] as any) ? new Date(n[1]).getTime() : Number(n[1]);
161
+ ret[2] = isNaN(n[2] as any) ? new Date(n[2]).getTime() : Number(n[2]);
162
+ return ret;
163
+ });
164
+
165
+ this._gantt._minStart = d3Min(ganttData, n => n[1]);
166
+ this._gantt._maxEnd = d3Max(ganttData, n => n[2]);
167
+ this._gantt.data(ganttData);
168
+ }
169
+ return retVal;
170
+ }
171
+
172
+ resize(_size?: { width: number, height: number }) {
173
+ const retVal = super.resize.apply(this, arguments);
174
+
175
+ if (this._topAxisElement) {
176
+ this.resizeWrappers();
177
+ }
178
+
179
+ return retVal;
180
+ }
181
+
182
+ click(row, col, sel) {
183
+
184
+ }
185
+
186
+ dblclick(row, col, sel) {
187
+
188
+ }
189
+
190
+ tooltip() {
191
+ return this._gantt._tooltip;
192
+ }
193
+ }
194
+ ReactAxisGanttSeries.prototype._class += " timeline_ReactAxisGanttSeries";
195
+
196
+ export interface ReactAxisGanttSeries {
197
+ tickFormat(): string;
198
+ tickFormat(_: string): this;
199
+ tickFormat_exists(): boolean;
200
+ overlapTolerence(): number;
201
+ overlapTolerence(_: number): this;
202
+ smallestRangeWidth(): number;
203
+ smallestRangeWidth(_: number): this;
204
+ scaleMode(): boolean;
205
+ scaleMode(_: boolean): this;
206
+ fontSize(): number;
207
+ fontSize(_: number): this;
208
+ fontFamily(): string;
209
+ fontFamily(_: string): this;
210
+ strokeWidth(): number;
211
+ strokeWidth(_: number): this;
212
+ stroke(): string;
213
+ stroke(_: string): this;
214
+ cornerRadius(): number;
215
+ cornerRadius(_: number): this;
216
+ axisFontSize(): number;
217
+ axisFontSize(_: number): this;
218
+ axisFontFamily(): string;
219
+ axisFontFamily(_: string): this;
220
+ axisTickLength(): number;
221
+ axisTickLength(_: number): this;
222
+ axisHeight(): number;
223
+ axisHeight(_: number): this;
224
+ titleColumn(): string;
225
+ titleColumn(_: string): this;
226
+ startDateColumn(): string;
227
+ startDateColumn(_: string): this;
228
+ endDateColumn(): string;
229
+ endDateColumn(_: string): this;
230
+ iconColumn(): string;
231
+ iconColumn(_: string): this;
232
+ colorColumn(): string;
233
+ colorColumn(_: string): this;
234
+ seriesColumn(): string;
235
+ seriesColumn(_: string): this;
236
+ bucketColumn(): string;
237
+ bucketColumn(_: string): this;
238
+ maxZoom(): number;
239
+ maxZoom(_: number): this;
240
+ preserveZoom(): boolean;
241
+ preserveZoom(_: boolean): this;
242
+ }
243
+ ReactAxisGanttSeries.prototype.publish("tickFormat", null, "string", "Format rule applied to axis tick labels", undefined, { optional: true });
244
+ ReactAxisGanttSeries.prototype.publish("axisHeight", 22, "number", "Height of axes (pixels)");
245
+ ReactAxisGanttSeries.prototype.publish("overlapTolerence", 2, "number", "overlapTolerence");
246
+ ReactAxisGanttSeries.prototype.publish("smallestRangeWidth", 10, "number", "Width of the shortest range (pixels)");
247
+ ReactAxisGanttSeries.prototype.publish("axisFontSize", null, "number", "Font size of axis tick labels");
248
+ ReactAxisGanttSeries.prototype.publish("axisFontFamily", null, "string", "Font family of axis tick labels");
249
+ ReactAxisGanttSeries.prototype.publish("axisTickLength", null, "number", "Length of axis ticks");
250
+ ReactAxisGanttSeries.prototype.publishProxy("gutter", "_gantt");
251
+ ReactAxisGanttSeries.prototype.publishProxy("renderMode", "_gantt");
252
+ ReactAxisGanttSeries.prototype.publishProxy("strokeWidth", "_gantt");
253
+ ReactAxisGanttSeries.prototype.publishProxy("fontSize", "_gantt");
254
+ ReactAxisGanttSeries.prototype.publishProxy("fontFamily", "_gantt");
255
+ ReactAxisGanttSeries.prototype.publishProxy("stroke", "_gantt");
256
+ ReactAxisGanttSeries.prototype.publishProxy("cornerRadius", "_gantt");
257
+ ReactAxisGanttSeries.prototype.publishProxy("titleColumn", "_gantt");
258
+ ReactAxisGanttSeries.prototype.publishProxy("startDateColumn", "_gantt");
259
+ ReactAxisGanttSeries.prototype.publishProxy("endDateColumn", "_gantt");
260
+ ReactAxisGanttSeries.prototype.publishProxy("iconColumn", "_gantt");
261
+ ReactAxisGanttSeries.prototype.publishProxy("colorColumn", "_gantt");
262
+ ReactAxisGanttSeries.prototype.publishProxy("seriesColumn", "_gantt");
263
+ ReactAxisGanttSeries.prototype.publishProxy("bucketColumn", "_gantt");
264
+ ReactAxisGanttSeries.prototype.publishProxy("maxZoom", "_gantt");
265
+ ReactAxisGanttSeries.prototype.publishProxy("preserveZoom", "_gantt");
266
+ ReactAxisGanttSeries.prototype.publishProxy("evenSeriesBackground", "_gantt");
267
+ ReactAxisGanttSeries.prototype.publishProxy("oddSeriesBackground", "_gantt");
268
+ ReactAxisGanttSeries.prototype.publishProxy("bucketHeight", "_gantt");