@equinor/esv-intersection 3.0.0-beta.4 → 3.0.0-beta.6

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.
Files changed (76) hide show
  1. package/README.md +0 -1
  2. package/dist/components/axis.d.ts +1 -1
  3. package/dist/control/ZoomPanHandler.d.ts +1 -1
  4. package/dist/datautils/picks.d.ts +6 -6
  5. package/dist/datautils/schematicShapeGenerator.d.ts +7 -8
  6. package/dist/datautils/seismicimage.d.ts +1 -1
  7. package/dist/index.esm.js +1 -1
  8. package/dist/index.js +1 -1
  9. package/dist/index.umd.js +1 -272
  10. package/dist/interfaces.d.ts +1 -1
  11. package/dist/layers/CalloutCanvasLayer.d.ts +2 -2
  12. package/dist/layers/CustomDisplayObjects/ComplexRope.d.ts +1 -1
  13. package/dist/layers/GeomodelCanvasLayer.d.ts +1 -1
  14. package/dist/layers/ImageCanvasLayer.d.ts +1 -1
  15. package/dist/layers/ReferenceLineLayer.d.ts +29 -0
  16. package/dist/layers/SchematicLayer.d.ts +10 -1
  17. package/dist/layers/SeismicCanvasLayer.d.ts +2 -3
  18. package/dist/layers/index.d.ts +1 -0
  19. package/dist/layers/schematicInterfaces.d.ts +13 -12
  20. package/dist/utils/arc-length.d.ts +1 -1
  21. package/dist/utils/root-finder.d.ts +1 -1
  22. package/package.json +38 -33
  23. package/src/components/axis.ts +247 -0
  24. package/src/components/index.ts +1 -0
  25. package/src/constants.ts +17 -0
  26. package/src/control/ExtendedCurveInterpolator.ts +155 -0
  27. package/src/control/IntersectionReferenceSystem.ts +391 -0
  28. package/src/control/LayerManager.ts +294 -0
  29. package/src/control/MainController.ts +296 -0
  30. package/src/control/ZoomPanHandler.ts +436 -0
  31. package/src/control/index.ts +5 -0
  32. package/src/control/interfaces.ts +42 -0
  33. package/src/control/overlay.ts +118 -0
  34. package/src/datautils/camelcase.ts +28 -0
  35. package/src/datautils/colortable.ts +14 -0
  36. package/src/datautils/findsample.ts +64 -0
  37. package/src/datautils/index.ts +6 -0
  38. package/src/datautils/interfaces.ts +68 -0
  39. package/src/datautils/picks.ts +328 -0
  40. package/src/datautils/schematicShapeGenerator.ts +1013 -0
  41. package/src/datautils/seismicimage.ts +180 -0
  42. package/src/datautils/surfacedata.ts +318 -0
  43. package/src/datautils/trajectory.ts +206 -0
  44. package/src/index.ts +6 -0
  45. package/src/interfaces.ts +99 -0
  46. package/src/layers/CalloutCanvasLayer.ts +338 -0
  47. package/src/layers/CustomDisplayObjects/ComplexRope.ts +45 -0
  48. package/src/layers/CustomDisplayObjects/ComplexRopeGeometry.ts +190 -0
  49. package/src/layers/CustomDisplayObjects/FixedWidthSimpleRope.ts +41 -0
  50. package/src/layers/CustomDisplayObjects/FixedWidthSimpleRopeGeometry.ts +149 -0
  51. package/src/layers/CustomDisplayObjects/UniformTextureStretchRope.ts +39 -0
  52. package/src/layers/CustomDisplayObjects/UniformTextureStretchRopeGeometry.ts +174 -0
  53. package/src/layers/GeomodelCanvasLayer.ts +176 -0
  54. package/src/layers/GeomodelLabelsLayer.ts +619 -0
  55. package/src/layers/GeomodelLayerV2.ts +110 -0
  56. package/src/layers/GridLayer.ts +145 -0
  57. package/src/layers/ImageCanvasLayer.ts +55 -0
  58. package/src/layers/ReferenceLineLayer.ts +185 -0
  59. package/src/layers/SchematicLayer.ts +896 -0
  60. package/src/layers/SeismicCanvasLayer.ts +46 -0
  61. package/src/layers/WellborePathLayer.ts +129 -0
  62. package/src/layers/base/CanvasLayer.ts +102 -0
  63. package/src/layers/base/HTMLLayer.ts +70 -0
  64. package/src/layers/base/Layer.ts +217 -0
  65. package/src/layers/base/PixiLayer.ts +190 -0
  66. package/src/layers/base/SVGLayer.ts +63 -0
  67. package/src/layers/base/index.ts +5 -0
  68. package/src/layers/index.ts +16 -0
  69. package/src/layers/schematicInterfaces.ts +470 -0
  70. package/src/utils/arc-length.ts +66 -0
  71. package/src/utils/binary-search.ts +26 -0
  72. package/src/utils/color.ts +22 -0
  73. package/src/utils/index.ts +1 -0
  74. package/src/utils/root-finder.ts +78 -0
  75. package/src/utils/text.ts +88 -0
  76. package/src/utils/vectorUtils.ts +67 -0
@@ -75,7 +75,7 @@ export interface Trajectory {
75
75
  points: number[][];
76
76
  offset: number;
77
77
  }
78
- export declare type BoundingBox = {
78
+ export type BoundingBox = {
79
79
  x: number;
80
80
  y: number;
81
81
  width: number;
@@ -2,11 +2,11 @@ import { ScaleLinear } from 'd3-scale';
2
2
  import { CanvasLayer } from './base/CanvasLayer';
3
3
  import { OnUpdateEvent, Annotation, OnRescaleEvent, BoundingBox } from '../interfaces';
4
4
  import { LayerOptions } from './base/Layer';
5
- export declare type Point = {
5
+ export type Point = {
6
6
  x: number;
7
7
  y: number;
8
8
  };
9
- export declare type Callout = {
9
+ export type Callout = {
10
10
  title: string;
11
11
  label: string;
12
12
  color: string;
@@ -1,5 +1,5 @@
1
1
  import { Mesh, IPoint, Renderer, Texture } from 'pixi.js';
2
- export declare type ComplexRopeSegment = {
2
+ export type ComplexRopeSegment = {
3
3
  points: IPoint[];
4
4
  diameter: number;
5
5
  };
@@ -2,7 +2,7 @@ import { SurfaceData, SurfaceLine } from '../datautils';
2
2
  import { OnUpdateEvent, OnRescaleEvent } from '../interfaces';
3
3
  import { LayerOptions } from './base';
4
4
  import { CanvasLayer } from './base/CanvasLayer';
5
- declare type SurfacePaths = {
5
+ type SurfacePaths = {
6
6
  color: string;
7
7
  path: Path2D;
8
8
  };
@@ -10,7 +10,7 @@ export interface OnImageLayerUpdateEvent<T> extends OnUpdateEvent<T> {
10
10
  x?: number;
11
11
  y?: number;
12
12
  }
13
- export declare type OnImageLayerRescaleEvent<T> = OnImageLayerUpdateEvent<T> & OnRescaleEvent;
13
+ export type OnImageLayerRescaleEvent<T> = OnImageLayerUpdateEvent<T> & OnRescaleEvent;
14
14
  export declare class ImageLayer<T> extends CanvasLayer<T> {
15
15
  img: HTMLImageElement;
16
16
  onMount(event: OnMountEvent): void;
@@ -0,0 +1,29 @@
1
+ import { CanvasLayer, LayerOptions } from './base';
2
+ import { OnUpdateEvent, OnRescaleEvent, OnMountEvent } from '../interfaces';
3
+ import { ScaleLinear } from 'd3-scale';
4
+ export type ReferenceLineType = 'wavy' | 'dashed' | 'solid';
5
+ export type ReferenceLine = {
6
+ text?: string;
7
+ lineType: ReferenceLineType;
8
+ color: string;
9
+ depth: number;
10
+ lineWidth?: number;
11
+ textColor?: string;
12
+ fontSize?: string;
13
+ };
14
+ export interface ReferenceLineLayerOptions extends LayerOptions<ReferenceLine[]> {
15
+ }
16
+ export declare class ReferenceLineLayer extends CanvasLayer<ReferenceLine[]> {
17
+ yScale: ScaleLinear<number, number, never> | null;
18
+ xScale: ScaleLinear<number, number, never> | null;
19
+ onMount(event: OnMountEvent): void;
20
+ onUpdate(event: OnUpdateEvent<ReferenceLine[]>): void;
21
+ onRescale(event: OnRescaleEvent): void;
22
+ private drawDashed;
23
+ private drawSolid;
24
+ private drawWavy;
25
+ private drawText;
26
+ private setCtxLineStyle;
27
+ private setCtxLineWidth;
28
+ private render;
29
+ }
@@ -65,12 +65,12 @@ export declare class SchematicLayer<T extends SchematicData> extends PixiLayer<T
65
65
  * @param lineAlignment alignment of the line to draw, (0 = inner, 0.5 = middle, 1 = outer).
66
66
  */
67
67
  protected drawCasingWindowOutline(leftPath: Point[], rightPath: Point[], { lineColor, windowOptions }: CasingOptions, lineWidth?: number): void;
68
+ private perforationRopeAndTextureReferences;
68
69
  preRender(): void;
69
70
  private updateSymbolCache;
70
71
  private drawCementPlug;
71
72
  private createCasingRenderObject;
72
73
  private getCementPlugTexture;
73
- private createPerforationTexture;
74
74
  private prepareSymbolRenderObject;
75
75
  private drawSymbolComponent;
76
76
  private drawSVGRope;
@@ -86,6 +86,15 @@ export declare class SchematicLayer<T extends SchematicData> extends PixiLayer<T
86
86
  * @returns ordered rendering list
87
87
  */
88
88
  private sortCementAndCasingRenderObjects;
89
+ /**
90
+ *
91
+ * @param intervals
92
+ * @param texture
93
+ * optionally fetch the exaggerationFactor from a different options prop
94
+ * options.perforationOptions for example
95
+ * @param getExaggerationFactor
96
+ * @returns
97
+ */
89
98
  private drawComplexRope;
90
99
  private static getOutlineClosureType;
91
100
  private drawCasing;
@@ -1,13 +1,12 @@
1
- /// <reference types="offscreencanvas" />
2
1
  import { CanvasLayer } from './base/CanvasLayer';
3
2
  import { OnUpdateEvent, OnMountEvent, OnRescaleEvent } from '../interfaces';
4
- export declare type SeismicCanvasDataOptions = {
3
+ export type SeismicCanvasDataOptions = {
5
4
  x: number;
6
5
  y: number;
7
6
  width: number;
8
7
  height: number;
9
8
  };
10
- export declare type SeismicCanvasData = {
9
+ export type SeismicCanvasData = {
11
10
  image: CanvasImageSource | OffscreenCanvas;
12
11
  options: SeismicCanvasDataOptions;
13
12
  };
@@ -13,3 +13,4 @@ export * from './ImageCanvasLayer';
13
13
  export * from './SchematicLayer';
14
14
  export * from './SeismicCanvasLayer';
15
15
  export * from './WellborePathLayer';
16
+ export * from './ReferenceLineLayer';
@@ -2,7 +2,7 @@ export declare function assertNever(x: never): never;
2
2
  /**
3
3
  * The closure type of the outline
4
4
  */
5
- export declare type OutlineClosure = 'None' | 'TopAndBottom' | 'Top' | 'Bottom';
5
+ export type OutlineClosure = 'None' | 'TopAndBottom' | 'Top' | 'Bottom';
6
6
  export interface HoleSize {
7
7
  kind: 'hole';
8
8
  id: string;
@@ -58,7 +58,7 @@ export interface CementPlug {
58
58
  referenceIds: string[];
59
59
  }
60
60
  export declare const isCementPlug: (item: PAndA) => item is CementSqueeze;
61
- export declare type PAndA = PAndASymbol | CementSqueeze | CementPlug;
61
+ export type PAndA = PAndASymbol | CementSqueeze | CementPlug;
62
62
  interface BaseCompletion {
63
63
  id: string;
64
64
  diameter: number;
@@ -75,7 +75,7 @@ export interface CompletionSymbol extends BaseCompletion {
75
75
  kind: 'completionSymbol';
76
76
  symbolKey: string;
77
77
  }
78
- export declare type Completion = Tubing | Screen | CompletionSymbol;
78
+ export type Completion = Tubing | Screen | CompletionSymbol;
79
79
  export declare const foldCompletion: <T>(fScreen: (obj: Screen) => T, fTubing: (obj: Tubing) => T, fSymbol: (obj: CompletionSymbol) => T) => (completion: Completion) => T;
80
80
  export interface Cement {
81
81
  kind: 'cement';
@@ -89,7 +89,7 @@ export interface Cement {
89
89
  /**
90
90
  * 'Open hole' and 'Open hole screen' are not included as they are not visualized and also not included in the ruleset
91
91
  */
92
- export declare type PerforationSubKind = 'Perforation' | 'Open hole gravel pack' | 'Open hole frac pack' | 'Cased hole frac pack' | 'Cased hole gravel pack' | 'Cased hole fracturation';
92
+ export type PerforationSubKind = 'Perforation' | 'Open hole gravel pack' | 'Open hole frac pack' | 'Cased hole frac pack' | 'Cased hole gravel pack' | 'Cased hole fracturation';
93
93
  export interface Perforation {
94
94
  kind: 'perforation';
95
95
  subKind: PerforationSubKind;
@@ -100,10 +100,6 @@ export interface Perforation {
100
100
  * is the perforation open or sealed?
101
101
  */
102
102
  isOpen: boolean;
103
- /**
104
- * Referenced Casing ids
105
- */
106
- referenceIds: string[];
107
103
  }
108
104
  export declare const foldPerforationSubKind: <T>(options: {
109
105
  Perforation: (kind: 'Perforation') => T;
@@ -113,9 +109,12 @@ export declare const foldPerforationSubKind: <T>(options: {
113
109
  CasedHoleFracPack: (kind: 'Cased hole frac pack') => T;
114
110
  CasedHoleFracturation: (kind: 'Cased hole fracturation') => T;
115
111
  }, subKind: PerforationSubKind) => T;
116
- export declare const getPerforationsThatStartAtHoleDiameter: (perforations: Perforation[]) => Perforation[];
117
- export declare const getPerforationsThatSTartAtCasingDiameter: (perforations: Perforation[]) => Perforation[];
118
- export declare function hasGravelPack(perf: Perforation): boolean;
112
+ export declare const shouldPerforationStartAtHoleDiameter: (perf: Perforation) => boolean;
113
+ export declare const shouldPerforationStartAtCasingDiameter: (perf: Perforation) => boolean;
114
+ export declare const hasPacking: (perf: Perforation) => boolean;
115
+ export declare function hasFracLines(perf: Perforation): boolean;
116
+ export declare function hasSpikes(perf: Perforation): boolean;
117
+ export declare function isSubkindCasedHoleGravelPack(perf: Perforation): boolean;
119
118
  export declare function isSubKindPerforation(perf: Perforation): boolean;
120
119
  export declare function isSubKindCasedHoleFracPack(perf: Perforation): boolean;
121
120
  export declare function isOpenHoleFracPack(perf: Perforation): boolean;
@@ -167,11 +166,13 @@ export interface PerforationOptions {
167
166
  yellow: string;
168
167
  grey: string;
169
168
  red: string;
169
+ outline: string;
170
170
  transparent: string;
171
171
  spikeWidth: number;
172
+ spikeLength: number;
172
173
  packingOpacity: number;
173
174
  fracLineLength: number;
174
- fracLineHalfWidth: number;
175
+ fracLineCurve: number;
175
176
  scalingFactor: number;
176
177
  }
177
178
  export declare const defaultPerforationOptions: PerforationOptions;
@@ -1,5 +1,5 @@
1
1
  import { Vector } from 'curve-interpolator/dist/src/interfaces';
2
- declare type fx = (n: number) => Vector;
2
+ type fx = (n: number) => Vector;
3
3
  export declare class ArcLength {
4
4
  /**
5
5
  * Calculate using an adaptive bisect method
@@ -1,4 +1,4 @@
1
- declare type fx = (n: number) => number;
1
+ type fx = (n: number) => number;
2
2
  export declare class RootFinder {
3
3
  /**
4
4
  * Find root using newthons method
package/package.json CHANGED
@@ -1,17 +1,22 @@
1
1
  {
2
2
  "name": "@equinor/esv-intersection",
3
- "version": "3.0.0-beta.4",
3
+ "version": "3.0.0-beta.6",
4
4
  "description": "Intersection component package with testing and automatic documentation.",
5
- "main": "dist/index.js",
6
- "module": "dist/index.esm.js",
7
- "browser": "dist/index.umd.js",
5
+ "type": "module",
6
+ "exports": {
7
+ "import": "./dist/index.esm.js",
8
+ "require": "./dist/index.js",
9
+ "browser": "./dist/index.umd.js"
10
+ },
8
11
  "files": [
9
- "dist"
12
+ "dist/*",
13
+ "src/*",
14
+ "!test/*"
10
15
  ],
11
16
  "types": "dist/index.d.ts",
12
17
  "scripts": {
13
18
  "prebuild": "rimraf dist",
14
- "build": "rollup -c",
19
+ "build": "rollup -c --bundleConfigAsCjs",
15
20
  "prepub": "npm run build",
16
21
  "pub": "npm publish --access=public",
17
22
  "prepub-beta": "npm run build",
@@ -42,40 +47,40 @@
42
47
  },
43
48
  "homepage": "https://github.com/equinor/esv-intersection#readme",
44
49
  "devDependencies": {
45
- "@babel/core": "^7.19.1",
46
- "@babel/preset-env": "^7.19.1",
50
+ "@babel/core": "^7.20.5",
51
+ "@babel/preset-env": "^7.20.2",
47
52
  "@babel/preset-typescript": "^7.18.6",
48
- "@storybook/addon-docs": "^6.5.12",
49
- "@storybook/addon-storysource": "^6.5.12",
50
- "@storybook/html": "^6.5.12",
53
+ "@rollup/plugin-commonjs": "^23.0.5",
54
+ "@rollup/plugin-node-resolve": "^15.0.1",
55
+ "@rollup/plugin-terser": "^0.2.0",
56
+ "@storybook/addon-docs": "^6.5.14",
57
+ "@storybook/addon-storysource": "^6.5.14",
58
+ "@storybook/html": "^6.5.14",
51
59
  "@types/d3": "^7.4.0",
52
- "@types/jest": "^29.0.2",
60
+ "@types/jest": "^29.2.4",
53
61
  "@types/mock-raf": "^1.0.3",
54
- "@typescript-eslint/eslint-plugin": "^5.37.0",
55
- "@typescript-eslint/parser": "^5.37.0",
56
- "babel-jest": "^29.0.3",
62
+ "@typescript-eslint/eslint-plugin": "^5.46.1",
63
+ "@typescript-eslint/parser": "^5.46.1",
64
+ "babel-jest": "^29.3.1",
57
65
  "copyfiles": "^2.4.1",
58
- "eslint": "^8.23.1",
66
+ "eslint": "^8.29.0",
59
67
  "eslint-config-prettier": "^8.5.0",
60
68
  "eslint-plugin-prettier": "^4.2.1",
61
- "eslint-plugin-storybook": "^0.6.4",
62
- "jest": "^29.0.3",
69
+ "eslint-plugin-storybook": "^0.6.8",
70
+ "jest": "^29.3.1",
63
71
  "jest-canvas-mock": "^2.4.0",
64
- "jest-environment-jsdom": "^29.0.3",
72
+ "jest-environment-jsdom": "^29.3.1",
65
73
  "mock-raf": "^1.0.1",
66
- "pixi.js": "^6.5.8",
67
74
  "pixi-dashed-line": "^1.4.2",
68
- "prettier": "^2.7.1",
75
+ "pixi.js": "^6.5.8",
76
+ "prettier": "^2.8.1",
69
77
  "rimraf": "^3.0.2",
70
- "rollup": "^2.79.0",
71
- "rollup-plugin-commonjs": "^10.1.0",
72
- "rollup-plugin-node-resolve": "^5.2.0",
73
- "rollup-plugin-terser": "^7.0.2",
74
- "rollup-plugin-typescript2": "^0.34.0",
75
- "storybook-dark-mode": "^1.1.2",
76
- "tslib": "^2.4.0",
77
- "typedoc": "^0.23.14",
78
- "typescript": "^4.8.3"
78
+ "rollup": "^3.7.4",
79
+ "rollup-plugin-typescript2": "^0.34.1",
80
+ "storybook-dark-mode": "^2.0.4",
81
+ "tslib": "^2.4.1",
82
+ "typedoc": "^0.23.22",
83
+ "typescript": "^4.9.4"
79
84
  },
80
85
  "jest": {
81
86
  "setupFiles": [
@@ -93,14 +98,14 @@
93
98
  ]
94
99
  },
95
100
  "peerDependencies": {
96
- "pixi.js": "^6.5.8",
97
- "pixi-dashed-line": "^1.4.2"
101
+ "pixi-dashed-line": "^1.4.2",
102
+ "pixi.js": "^6.5.8"
98
103
  },
99
104
  "dependencies": {
100
105
  "@equinor/videx-math": "^1.1.0",
101
106
  "@equinor/videx-vector2": "^1.0.44",
102
107
  "curve-interpolator": "2.0.8",
103
- "d3-array": "^3.2.0",
108
+ "d3-array": "^3.2.1",
104
109
  "d3-axis": "^3.0.0",
105
110
  "d3-scale": "^4.0.2",
106
111
  "d3-selection": "^3.0.0",
@@ -0,0 +1,247 @@
1
+ import { axisRight, axisBottom } from 'd3-axis';
2
+ import { BaseType, Selection } from 'd3-selection';
3
+ import { ScaleLinear, scaleLinear } from 'd3-scale';
4
+ import { OnResizeEvent, OnRescaleEvent } from '../interfaces';
5
+
6
+ export type Options = {
7
+ offsetX: number;
8
+ offsetY: number;
9
+ visible: boolean;
10
+ };
11
+
12
+ export class Axis {
13
+ private mainGroup: Selection<SVGElement, unknown, null, undefined>;
14
+ private _scaleX: ScaleLinear<number, number>;
15
+ private _scaleY: ScaleLinear<number, number>;
16
+ private _showLabels = true;
17
+ private _labelXDesc: string;
18
+ private _labelYDesc: string;
19
+ private _unitOfMeasure: string;
20
+ private _offsetX: number = 0;
21
+ private _offsetY: number = 0;
22
+ private _flipX = false;
23
+ private _flipY = false;
24
+ private visible: boolean = true;
25
+
26
+ constructor(
27
+ mainGroup: Selection<SVGElement, unknown, null, undefined>,
28
+ showLabels = true,
29
+ labelXDesc: string,
30
+ labelYDesc: string,
31
+ unitOfMeasure: string,
32
+ options?: Options,
33
+ ) {
34
+ this.mainGroup = mainGroup;
35
+ this._showLabels = showLabels;
36
+ this._labelXDesc = labelXDesc;
37
+ this._labelYDesc = labelYDesc;
38
+ this._unitOfMeasure = unitOfMeasure;
39
+ if (options && options.offsetX) {
40
+ this._offsetX = options.offsetX;
41
+ }
42
+ if (options && options.offsetX) {
43
+ this._offsetY = options.offsetY;
44
+ }
45
+ if (options && options.visible) {
46
+ this.visible = options.visible;
47
+ }
48
+ this.mainGroup.style('pointer-events', 'none');
49
+
50
+ this._scaleX = scaleLinear().domain([0, 1]).range([0, 1]);
51
+ this._scaleY = scaleLinear().domain([0, 1]).range([0, 1]);
52
+ }
53
+
54
+ private renderLabelx(): Selection<BaseType, unknown, null, undefined> {
55
+ const { _labelXDesc: labelXDesc, _unitOfMeasure: unitOfMeasure, _showLabels, _scaleX: scaleX } = this;
56
+ const [, width] = scaleX.range();
57
+ const gx = this.renderGx();
58
+
59
+ let labelx = gx.select('text.axis-labelx');
60
+ if (_showLabels) {
61
+ if (labelx.empty()) {
62
+ labelx = gx
63
+ .append('text')
64
+ .attr('class', 'axis-labelx')
65
+ .attr('fill', 'rgba(0,0,0,0.3)')
66
+ .style('text-anchor', 'middle')
67
+ .style('font-weight', '800')
68
+ .style('font-size', '10px')
69
+ .text(`${labelXDesc} (${unitOfMeasure})`);
70
+ }
71
+ } else {
72
+ labelx.remove();
73
+ }
74
+ labelx.attr('transform', `translate(${width / 2},-4)`);
75
+ return labelx;
76
+ }
77
+
78
+ private renderLabely(): Selection<BaseType, unknown, null, undefined> {
79
+ const { _labelYDesc: labelYDesc, _unitOfMeasure: unitOfMeasure, _showLabels, _scaleY } = this;
80
+ const [, height] = _scaleY.range();
81
+ const gy = this.renderGy();
82
+
83
+ let labely = gy.select('text.axis-labely');
84
+ if (_showLabels) {
85
+ if (labely.empty()) {
86
+ labely = gy
87
+ .append('text')
88
+ .attr('class', 'axis-labely')
89
+ .attr('fill', 'rgba(0,0,0,0.3)')
90
+ .style('text-anchor', 'middle')
91
+ .style('font-weight', '800')
92
+ .style('font-size', '10px')
93
+ .text(`${labelYDesc} (${unitOfMeasure})`);
94
+ }
95
+ labely.attr('transform', `translate(-10,${height / 2})rotate(90)`);
96
+ } else {
97
+ labely.remove();
98
+ }
99
+ return labely;
100
+ }
101
+
102
+ private renderGy(): Selection<BaseType, unknown, null, undefined> {
103
+ const { _scaleX, _scaleY } = this;
104
+ const yAxis = axisRight(_scaleY) as (selection: Selection<SVGSVGElement, unknown, null, undefined>) => void;
105
+ const [, width] = _scaleX.range();
106
+ const gy = this.createOrGet('y-axis');
107
+ gy.call(yAxis);
108
+ gy.attr('transform', `translate(${width},0)`);
109
+
110
+ return gy;
111
+ }
112
+
113
+ private renderGx(): Selection<BaseType, unknown, null, undefined> {
114
+ const { _scaleX, _scaleY } = this;
115
+ const xAxis = axisBottom(_scaleX) as (selection: Selection<SVGSVGElement, unknown, null, undefined>) => void;
116
+ const [, height] = _scaleY.range();
117
+
118
+ const gx = this.createOrGet('x-axis');
119
+ gx.attr('transform', `translate(0 ${height})`);
120
+ gx.call(xAxis);
121
+ return gx;
122
+ }
123
+
124
+ private createOrGet = (name: string): Selection<BaseType, unknown, null, undefined> => {
125
+ const { mainGroup } = this;
126
+ let res = mainGroup.select(`g.${name}`);
127
+ if (res.empty()) {
128
+ res = mainGroup.append('g').attr('class', name);
129
+ }
130
+ return res;
131
+ };
132
+
133
+ render(): void {
134
+ this.renderLabelx();
135
+ this.renderLabely();
136
+ }
137
+
138
+ onResize(event: OnResizeEvent): void {
139
+ this.mainGroup.attr('height', `${event.height}px`).attr('width', `${event.width}px`);
140
+ }
141
+
142
+ onRescale(event: OnRescaleEvent): void {
143
+ const { _scaleX, _scaleY, offsetX, offsetY } = this;
144
+ const { xScale, yScale } = event;
145
+ const xBounds = xScale.domain();
146
+ const yBounds = yScale.domain();
147
+
148
+ const xRange = xScale.range();
149
+ const yRange = yScale.range();
150
+
151
+ _scaleX.domain([xBounds[0] - offsetX, xBounds[1] - offsetX]).range(xRange);
152
+ _scaleY.domain([yBounds[0] - offsetY, yBounds[1] - offsetY]).range(yRange);
153
+ this.flipX(this._flipX);
154
+ this.flipY(this._flipY);
155
+
156
+ if (this.visible) {
157
+ this.render();
158
+ }
159
+ }
160
+
161
+ show(): Axis {
162
+ this.visible = true;
163
+ this.mainGroup.attr('visibility', 'visible');
164
+ this.render();
165
+ return this;
166
+ }
167
+
168
+ hide(): Axis {
169
+ this.visible = false;
170
+ this.mainGroup.attr('visibility', 'hidden');
171
+ return this;
172
+ }
173
+
174
+ flipX(flipX: boolean): Axis {
175
+ this._flipX = flipX;
176
+ const domain = this._scaleX.domain();
177
+ const flip = flipX ? -1 : 1;
178
+ this._scaleX.domain([flip * domain[0], flip * domain[1]]);
179
+ return this;
180
+ }
181
+
182
+ flipY(flipY: boolean): Axis {
183
+ this._flipY = flipY;
184
+ const domain = this._scaleY.domain();
185
+ const flip = flipY ? -1 : 1;
186
+ this._scaleY.domain([flip * domain[0], flip * domain[1]]);
187
+ return this;
188
+ }
189
+
190
+ showLabels(): Axis {
191
+ this._showLabels = true;
192
+ this.render();
193
+ return this;
194
+ }
195
+
196
+ hideLabels(): Axis {
197
+ this._showLabels = false;
198
+ this.render();
199
+ return this;
200
+ }
201
+
202
+ setLabelX(label: string): Axis {
203
+ this._labelXDesc = label;
204
+ return this;
205
+ }
206
+
207
+ setLabelY(label: string): Axis {
208
+ this._labelYDesc = label;
209
+ return this;
210
+ }
211
+
212
+ setUnitOfMeasure(uom: string): Axis {
213
+ this._unitOfMeasure = uom;
214
+ return this;
215
+ }
216
+
217
+ setLabels(labelX: string, labelY: string, unitOfMeasure: string): Axis {
218
+ this._labelXDesc = labelX;
219
+ this._labelYDesc = labelY;
220
+ this._unitOfMeasure = unitOfMeasure;
221
+ return this;
222
+ }
223
+
224
+ get offsetX(): number {
225
+ return this._offsetX;
226
+ }
227
+
228
+ set offsetX(offset: number) {
229
+ this._offsetX = offset;
230
+ }
231
+
232
+ get offsetY(): number {
233
+ return this._offsetY;
234
+ }
235
+
236
+ set offsetY(offset: number) {
237
+ this._offsetY = offset;
238
+ }
239
+
240
+ get scaleX(): ScaleLinear<number, number> {
241
+ return this._scaleX.copy();
242
+ }
243
+
244
+ get scaleY(): ScaleLinear<number, number> {
245
+ return this._scaleY.copy();
246
+ }
247
+ }
@@ -0,0 +1 @@
1
+ export * from './axis';
@@ -0,0 +1,17 @@
1
+ export const DEFAULT_LAYER_WIDTH = 200;
2
+ export const DEFAULT_LAYER_HEIGHT = 300;
3
+
4
+ export const HORIZONTAL_AXIS_MARGIN = 40;
5
+ export const VERTICAL_AXIS_MARGIN = 30;
6
+
7
+ export const EXAGGERATED_DIAMETER = 100;
8
+ export const HOLE_OUTLINE = 0.6;
9
+ export const SCREEN_OUTLINE = 0.3;
10
+
11
+ export const SHOE_WIDTH = 8;
12
+ export const SHOE_LENGTH = 16;
13
+
14
+ export const DEFAULT_TEXTURE_SIZE = 64;
15
+
16
+ // Surface lines are drawn as LINES and not TRIANGLE_STRIP so width can only be 1
17
+ export const SURFACE_LINE_WIDTH = 1;