react-cheminfo 0.45.0 → 0.46.0

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.
@@ -72,18 +72,29 @@ export declare const DEFAULT_Y_AXIS_RULES: Required<YAxisRules>;
72
72
  * between forty and sixty percent", so a drag narrows the horizontal axis and
73
73
  * leaves the height alone unless it is released past the baseline.
74
74
  *
75
+ * `dual` is the same reading gesture with a gate a reader can predict: a drag
76
+ * kept level narrows the horizontal axis alone, and one taken far enough up or
77
+ * down brings the height with it. It is what `xAxis` cannot be on a chart whose
78
+ * vertical axis has no baseline to cross — a titration curve climbing from pH 2
79
+ * to pH 12, a speciation diagram drawn over decades — where "has the pointer
80
+ * passed zero" is a question about the margin rather than about the data, and
81
+ * the answer to it is no for every drag made inside the plot. Here both windows
82
+ * are asked for where the curve is, and the preview changes shape as the
83
+ * threshold is crossed, so the rectangle is found by the hand that was already
84
+ * drawing one.
85
+ *
75
86
  * `box` is the tool: while it is chosen, the rectangle dragged out is the window,
76
87
  * both axes at once. It is a mode rather than a modifier because it is used in
77
88
  * runs — a baseline being examined is examined several times over — and a
78
89
  * modifier held down through each of them is a worse gesture than a tool pressed
79
90
  * once.
80
91
  *
81
- * The two are named apart from the whole of `DragMode` so that a chart offering
82
- * nothing but zoom tools can say so in its own signature — which is what stops
83
- * `select`, the one drag that moves no axis, from reaching a chart with no
84
- * handler for it.
92
+ * The three are named apart from the whole of `DragMode` so that a chart
93
+ * offering nothing but zoom tools can say so in its own signature — which is
94
+ * what stops `select`, the one drag that moves no axis, from reaching a chart
95
+ * with no handler for it.
85
96
  */
86
- export type ZoomDragMode = 'xAxis' | 'box';
97
+ export type ZoomDragMode = 'xAxis' | 'dual' | 'box';
87
98
  /**
88
99
  * What a drag across the plot asks for.
89
100
  *
@@ -1 +1 @@
1
- {"version":3,"file":"chartDomain.d.ts","sourceRoot":"","sources":["../../../src/chart/core/chartDomain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;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AC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1B,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1B,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1B,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAC3B,CAAC;AACJ,CAAC"}
@@ -52,5 +52,5 @@ export { READOUT_GAP, READOUT_LINES, READOUT_WIDTH, readoutPlacement, } from './
52
52
  export type { ViewBox, ViewState, ZoomBounds } from './viewTransform.ts';
53
53
  export { INITIAL_VIEW, MAXIMUM_CONTENT_SCALE, MAXIMUM_ZOOM, MINIMUM_ZOOM, baseViewBox, clampZoom, magnificationOf, panBy, viewBoxAttribute, viewBoxOf, zoomAbout, zoomToAboutCentre, } from './viewTransform.ts';
54
54
  export type { DragBox, ZoomSelection } from './zoomDomain.ts';
55
- export { MINIMUM_DRAG, releasedBeyondBaseline, scaledYAxis, zoomSelection, zoomedDomain, } from './zoomDomain.ts';
55
+ export { DUAL_ZOOM_TRAVEL, MINIMUM_DRAG, draggedBeyondLevel, releasedBeyondBaseline, scaledYAxis, zoomSelection, zoomedDomain, } from './zoomDomain.ts';
56
56
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/chart/core/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,YAAY,EACV,cAAc,EACd,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,cAAc,GACf,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,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3C,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAClE,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EACL,WAAW,EACX,aAAa,EACb,aAAa,EACb,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,SAAS,EACT,eAAe,EACf,KAAK,EACL,gBAAgB,EAChB,SAAS,EACT,SAAS,EACT,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EAClB,sBAAsB,EACtB,WAAW,EACX,aAAa,EACb,YAAY,GACb,MAAM,iBAAiB,CAAC"}
@@ -33,5 +33,5 @@ export { svgPointAt } from "./svgPoint.js";
33
33
  export { areaPath, profilePath, stickPath } from "./tracePath.js";
34
34
  export { READOUT_GAP, READOUT_LINES, READOUT_WIDTH, readoutPlacement, } from "./trackerReadout.js";
35
35
  export { INITIAL_VIEW, MAXIMUM_CONTENT_SCALE, MAXIMUM_ZOOM, MINIMUM_ZOOM, baseViewBox, clampZoom, magnificationOf, panBy, viewBoxAttribute, viewBoxOf, zoomAbout, zoomToAboutCentre, } from "./viewTransform.js";
36
- export { MINIMUM_DRAG, releasedBeyondBaseline, scaledYAxis, zoomSelection, zoomedDomain, } from "./zoomDomain.js";
36
+ export { DUAL_ZOOM_TRAVEL, MINIMUM_DRAG, draggedBeyondLevel, releasedBeyondBaseline, scaledYAxis, zoomSelection, zoomedDomain, } from "./zoomDomain.js";
37
37
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/chart/core/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,cAAc,GACf,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAE9E,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAMhD,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9D,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1E,OAAO,EACL,UAAU,EACV,eAAe,EACf,UAAU,EACV,UAAU,GACX,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAErE,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAS5E,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAO1B,OAAO,EACL,YAAY,EACZ,MAAM,EACN,iBAAiB,EACjB,k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AM,gBAAgB,CAAC;AACtD,OAAO,EACL,YAAY,EACZ,UAAU,EACV,UAAU,EACV,WAAW,EACX,UAAU,GACX,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAOtD,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,OAAO,EACP,UAAU,EACV,MAAM,EACN,WAAW,EACX,SAAS,EACT,WAAW,EACX,WAAW,GACZ,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,eAAe,EACf,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,cAAc,EACd,YAAY,EACZ,eAAe,EACf,WAAW,EACX,aAAa,EACb,WAAW,GACZ,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAElE,OAAO,EACL,WAAW,EACX,aAAa,EACb,aAAa,EACb,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,SAAS,EACT,eAAe,EACf,KAAK,EACL,gBAAgB,EAChB,SAAS,EACT,SAAS,EACT,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EAClB,sBAAsB,EACtB,WAAW,EACX,aAAa,EACb,YAAY,GACb,MAAM,iBAAiB,CAAC"}
@@ -28,9 +28,10 @@ export interface SelectionRectangle {
28
28
  * A drag that takes the y axis with it is drawn at the height of the drag
29
29
  * itself, and one that asks for the x axis alone spans the whole plot.
30
30
  * That is the gesture announcing itself before the button is let go: the
31
- * rectangle changing shape as the pointer crosses the baseline is the only
32
- * warning a user gets that the release is about to move both axes, and it is one
33
- * they can still act on.
31
+ * rectangle changing shape — as the pointer crosses the baseline, or as a
32
+ * `dual` drag leaves the level it started on — is the only warning a user gets
33
+ * that the release is about to move both axes, and it is one they can still act
34
+ * on.
34
35
  *
35
36
  * A drag too short to zoom draws nothing at all. Below `MINIMUM_DRAG` the
36
37
  * release does nothing — most clicks made on a trackpad wobble by a pixel or two
@@ -1 +1 @@
1
- {"version":3,"file":"selectionGeometry.d.ts","sourceRoot":"","sources":["../../../src/chart/core/selectionGeometry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGrD,gDAAgD;AAChD,MAAM,WAAW,kBAAkB;IACjC,qBAAqB;IACrB,CAAC,EAAE,MAAM,CAAC;IACV,oBAAoB;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,sBAAsB;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,sBAAsB;IACtB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,aAAa,GAAG,IAAI,EAC/B,IAAI,EAAE,QAAQ,GACb,kBAAkB,GAAG,IAAI,CAe3B"}
1
+ {"version":3,"file":"selectionGeometry.d.ts","sourceRoot":"","sources":["../../../src/chart/core/selectionGeometry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGrD,gDAAgD;AAChD,MAAM,WAAW,kBAAkB;IACjC,qBAAqB;IACrB,CAAC,EAAE,MAAM,CAAC;IACV,oBAAoB;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,sBAAsB;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,sBAAsB;IACtB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,aAAa,GAAG,IAAI,EAC/B,IAAI,EAAE,QAAQ,GACb,kBAAkB,GAAG,IAAI,CAe3B"}
@@ -17,9 +17,10 @@ import { MINIMUM_DRAG } from "./zoomDomain.js";
17
17
  * A drag that takes the y axis with it is drawn at the height of the drag
18
18
  * itself, and one that asks for the x axis alone spans the whole plot.
19
19
  * That is the gesture announcing itself before the button is let go: the
20
- * rectangle changing shape as the pointer crosses the baseline is the only
21
- * warning a user gets that the release is about to move both axes, and it is one
22
- * they can still act on.
20
+ * rectangle changing shape — as the pointer crosses the baseline, or as a
21
+ * `dual` drag leaves the level it started on — is the only warning a user gets
22
+ * that the release is about to move both axes, and it is one they can still act
23
+ * on.
23
24
  *
24
25
  * A drag too short to zoom draws nothing at all. Below `MINIMUM_DRAG` the
25
26
  * release does nothing — most clicks made on a trackpad wobble by a pixel or two
@@ -1 +1 @@
1
- {"version":3,"file":"selectionGeometry.js","sourceRoot":"","sources":["../../../src/chart/core/selectionGeometry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAInD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAc/C;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,kBAAkB,CAChC,SAA+B,EAC/B,IAAc;IAEd,IAAI,SAAS,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAEpC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,SAAS,CAAC;IACzD,MAAM,IAAI,GAA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 -23,6 +23,18 @@ import type { ChartScale } from './chartScale.ts';
23
23
  * hundred down went somewhere.
24
24
  */
25
25
  export declare const MINIMUM_DRAG = 4;
26
+ /**
27
+ * How far a `dual` drag has to travel vertically before it brings the y axis
28
+ * with it, in user units of the SVG.
29
+ *
30
+ * Far enough above `MINIMUM_DRAG` that no drag meant to stay level reaches it by
31
+ * the tremor of a hand or the slope of a trackpad swipe, and near enough that
32
+ * the rectangle a reader wants costs one gesture rather than a reach for the
33
+ * margin. The preview changes shape on the pixel it is crossed, so the number
34
+ * itself never has to be learnt: the first drag that crosses it teaches the
35
+ * gesture, and the first that recrosses it back shows the way out.
36
+ */
37
+ export declare const DUAL_ZOOM_TRAVEL = 24;
26
38
  /** The two corners of a drag, in the user units of the SVG. */
27
39
  export interface DragBox {
28
40
  /** Where the press landed, horizontally. */
@@ -49,9 +61,9 @@ export interface ZoomSelection extends DragBox {
49
61
  * than by the rectangle itself — so what the preview promises and what letting
50
62
  * go actually does are the same test rather than two that have to agree.
51
63
  *
52
- * A `select` drag is therefore always a band, however far past the baseline it
53
- * strays: its answer is two numbers on one axis, so a preview that grew into a
54
- * rectangle would promise a height nobody is ever told about.
64
+ * Which answer a mode gives is `takesYAxis`'s business, so a `select` drag is
65
+ * always a band however far past the baseline it strays, and a `dual` drag
66
+ * becomes a rectangle the moment it has travelled `DUAL_ZOOM_TRAVEL`.
55
67
  * @param drag - The drag being made, `null` when none is.
56
68
  * @param yScale - The y axis as it is currently zoomed.
57
69
  * @param rules - How the y axis behaves and what a drag means, defaulting to a
@@ -59,6 +71,19 @@ export interface ZoomSelection extends DragBox {
59
71
  * @returns The selection to draw, `null` when there is no drag.
60
72
  */
61
73
  export declare function zoomSelection(drag: DragBox | null, yScale: ChartScale, rules?: ZoomRules): ZoomSelection | null;
74
+ /**
75
+ * Whether a drag has left the level it started on by enough to ask for the y
76
+ * axis as well.
77
+ *
78
+ * Measured as the hand made it, before any clamping to the plot: a drag that ran
79
+ * out over the tick labels travelled however far it travelled. Nothing is
80
+ * latched — the answer is read off the two corners and nothing else — so a
81
+ * reader who drifted down and came back up is promised a band again, and the
82
+ * preview says so while the button is still down.
83
+ * @param drag - The drag being made or released, in user units of the SVG.
84
+ * @returns Whether the height comes along.
85
+ */
86
+ export declare function draggedBeyondLevel(drag: DragBox): boolean;
62
87
  /**
63
88
  * Whether a drag let go here asks for the y axis as well.
64
89
  *
@@ -1 +1 @@
1
- {"version":3,"file":"zoomDomain.d.ts","sourceRoot":"","sources":["../../../src/chart/core/zoomDomain.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY,IAAI,CAAC;AAE9B,+DAA+D;AAC/D,MAAM,WAAW,OAAO;IACtB,4CAA4C;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,8CAA8C;IAC9C,GAAG,EAAE,MAAM,CAAC;IACZ,8BAA8B;IAC9B,GAAG,EAAE,MAAM,CAAC;CACb;AAED,gFAAgF;AAChF,MAAM,WAAW,aAAc,SAAQ,OAAO;IAC5C;;;OAGG;IACH,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,OAAO,GAAG,IAAI,EACpB,MAAM,EAAE,UAAU,EAClB,KAAK,GAAE,SAAc,GACpB,aAAa,GAAG,IAAI,CAoBtB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,UAAU,EAClB,QAAQ,SAAgC,EACx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AAM,EAAE,UAAU,EAClB,KAAK,GAAE,SAAc,GACpB,aAAa,GAAG,IAAI,CActB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAEzD;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,UAAU,EAClB,QAAQ,SAAgC,EACxC,UAAU,UAAkC,GAC3C,OAAO,CAIT;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,WAAW,EACpB,IAAI,EAAE,OAAO,EACb,IAAI,EAAE,QAAQ,EACd,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,UAAU,EAClB,KAAK,GAAE,SAAc,GACpB,WAAW,GAAG,IAAI,CAyCpB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,MAAM,EACd,QAAQ,SAAgC,GACvC,WAAW,CAOb"}
@@ -23,6 +23,18 @@ import { chartPixel, chartValue } from "./chartScale.js";
23
23
  * hundred down went somewhere.
24
24
  */
25
25
  export const MINIMUM_DRAG = 4;
26
+ /**
27
+ * How far a `dual` drag has to travel vertically before it brings the y axis
28
+ * with it, in user units of the SVG.
29
+ *
30
+ * Far enough above `MINIMUM_DRAG` that no drag meant to stay level reaches it by
31
+ * the tremor of a hand or the slope of a trackpad swipe, and near enough that
32
+ * the rectangle a reader wants costs one gesture rather than a reach for the
33
+ * margin. The preview changes shape on the pixel it is crossed, so the number
34
+ * itself never has to be learnt: the first drag that crosses it teaches the
35
+ * gesture, and the first that recrosses it back shows the way out.
36
+ */
37
+ export const DUAL_ZOOM_TRAVEL = 24;
26
38
  /**
27
39
  * The drag as the preview rectangle needs it.
28
40
  *
@@ -30,9 +42,9 @@ export const MINIMUM_DRAG = 4;
30
42
  * than by the rectangle itself — so what the preview promises and what letting
31
43
  * go actually does are the same test rather than two that have to agree.
32
44
  *
33
- * A `select` drag is therefore always a band, however far past the baseline it
34
- * strays: its answer is two numbers on one axis, so a preview that grew into a
35
- * rectangle would promise a height nobody is ever told about.
45
+ * Which answer a mode gives is `takesYAxis`'s business, so a `select` drag is
46
+ * always a band however far past the baseline it strays, and a `dual` drag
47
+ * becomes a rectangle the moment it has travelled `DUAL_ZOOM_TRAVEL`.
36
48
  * @param drag - The drag being made, `null` when none is.
37
49
  * @param yScale - The y axis as it is currently zoomed.
38
50
  * @param rules - How the y axis behaves and what a drag means, defaulting to a
@@ -48,14 +60,24 @@ export function zoomSelection(drag, yScale, rules = {}) {
48
60
  fromY: drag.fromY,
49
61
  toX: drag.toX,
50
62
  toY: drag.toY,
51
- // The box tool takes the height always, so the preview is a rectangle from
52
- // the first pixel of the gesture rather than a full-height band that
53
- // suddenly becomes one; a select drag never takes it at all.
54
- zoomsYAxis: mode === 'box' ||
55
- (mode !== 'select' &&
56
- releasedBeyondBaseline(drag.toY, yScale, baseline, pointsDown)),
63
+ zoomsYAxis: takesYAxis(drag, mode, yScale, baseline, pointsDown),
57
64
  };
58
65
  }
66
+ /**
67
+ * Whether a drag has left the level it started on by enough to ask for the y
68
+ * axis as well.
69
+ *
70
+ * Measured as the hand made it, before any clamping to the plot: a drag that ran
71
+ * out over the tick labels travelled however far it travelled. Nothing is
72
+ * latched — the answer is read off the two corners and nothing else — so a
73
+ * reader who drifted down and came back up is promised a band again, and the
74
+ * preview says so while the button is still down.
75
+ * @param drag - The drag being made or released, in user units of the SVG.
76
+ * @returns Whether the height comes along.
77
+ */
78
+ export function draggedBeyondLevel(drag) {
79
+ return Math.abs(drag.toY - drag.fromY) >= DUAL_ZOOM_TRAVEL;
80
+ }
59
81
  /**
60
82
  * Whether a drag let go here asks for the y axis as well.
61
83
  *
@@ -124,21 +146,18 @@ export function zoomedDomain(current, drag, plot, xScale, yScale, rules = {}) {
124
146
  Math.min(firstX, secondX),
125
147
  Math.max(firstX, secondX),
126
148
  ];
127
- // The box tool is asked for the rectangle it was given, wherever it was let
128
- // go; the reading gesture takes the height only when it crossed the baseline.
129
- if (mode !== 'box' &&
130
- !releasedBeyondBaseline(drag.toY, yScale, baseline, pointsDown)) {
149
+ if (!takesYAxis(drag, mode, yScale, baseline, pointsDown)) {
131
150
  return { x, y: current.y };
132
151
  }
133
152
  const fromY = chartValue(yScale, clamp(drag.fromY, plot.top, plot.bottom));
134
153
  const toY = chartValue(yScale, clamp(drag.toY, plot.top, plot.bottom));
135
154
  // Both ends, so a baseline the data runs *down* from — 100 percent
136
- // transmittance — is kept as surely as one it stands on. The box tool holds no
137
- // baseline at all: a rectangle dragged round a feature is a promise about
138
- // exactly that rectangle, and a viewer whose axis rules keep its baseline
139
- // would otherwise see the tool quietly return a taller window than the one
140
- // drawn.
141
- const holdBaseline = keepBaseline && mode !== 'box';
155
+ // transmittance — is kept as surely as one it stands on. Only the reading
156
+ // gesture holds a baseline: a rectangle dragged out deliberately, by the box
157
+ // tool or by a `dual` drag that left its level, is a promise about exactly
158
+ // that rectangle, and a viewer whose axis rules keep its baseline would
159
+ // otherwise see a taller window than the one drawn.
160
+ const holdBaseline = keepBaseline && mode === 'xAxis';
142
161
  const bottom = holdBaseline
143
162
  ? Math.min(baseline, fromY, toY)
144
163
  : Math.min(fromY, toY);
@@ -172,4 +191,33 @@ export function scaledYAxis(current, factor, baseline = DEFAULT_Y_AXIS_RULES.bas
172
191
  ];
173
192
  return y[1] > y[0] ? { x: current.x, y } : current;
174
193
  }
194
+ /**
195
+ * Whether a drag brings the y axis with it, which is the one question the
196
+ * preview and the release must never answer differently.
197
+ *
198
+ * Asked once, here, rather than by each of them: a rectangle that promises a
199
+ * height the release then refuses teaches a reader that the chart is
200
+ * unreliable, and two copies of this test are how that comes about.
201
+ *
202
+ * The box tool takes the height always, so its preview is a rectangle from the
203
+ * first pixel of the gesture rather than a full-height band that suddenly
204
+ * becomes one. A `select` drag never takes it at all: its answer is two numbers
205
+ * on one axis, and a preview that grew into a rectangle would promise a height
206
+ * nobody is ever told about.
207
+ * @param drag - The drag being made or released, in user units of the SVG.
208
+ * @param mode - What a drag on this chart asks for.
209
+ * @param yScale - The y axis as it is currently zoomed.
210
+ * @param baseline - The value the reading gesture is judged against.
211
+ * @param pointsDown - Whether the data hangs below that baseline.
212
+ * @returns Whether the height comes along.
213
+ */
214
+ function takesYAxis(drag, mode, yScale, baseline, pointsDown) {
215
+ if (mode === 'box')
216
+ return true;
217
+ if (mode === 'select')
218
+ return false;
219
+ if (mode === 'dual')
220
+ return draggedBeyondLevel(drag);
221
+ return releasedBeyondBaseline(drag.toY, yScale, baseline, pointsDown);
222
+ }
175
223
  //# sourceMappingURL=zoomDomain.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"zoomDomain.js","sourceRoot":"","sources":["../../../src/chart/core/zoomDomain.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAGnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAGxD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEzD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC;AAuB9B;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,aAAa,CAC3B,IAAoB,EACpB,MAAkB,EAClB,QAAmB,EAAE;IAErB,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAC/B,MAAM,EACJ,QAAQ,GAAG,oBAAoB,CAAC,QAAQ,EACxC,UAAU,GAAG,oBAAoB,CAAC,UAAU,EAC5C,IAAI,EAAE,IAAI,GAAG,OAAO,GACrB,GAAG,KAAK,CAAC;IACV,OAAO;QACL,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,GAA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;IAChD,SAAS,EAAE,aAAa,GAAG,IAAI,CAAC;IAChC,yEAAyE;IACzE,IAAI,EAAE,QAAQ,CAAC;CAChB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,YAAY,GAAG,IAAI,CAgB5E"}
1
+ {"version":3,"file":"SelectionRect.d.ts","sourceRoot":"","sources":["../../../src/chart/ui/SelectionRect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAGzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,MAAM,WAAW,kBAAkB;IACjC,gDAAgD;IAChD,SAAS,EAAE,aAAa,GAAG,IAAI,CAAC;IAChC,yEAAyE;IACzE,IAAI,EAAE,QAAQ,CAAC;CAChB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,YAAY,GAAG,IAAI,CAoB5E"}
@@ -22,7 +22,7 @@ export function SelectionRect(props) {
22
22
  const rectangle = selectionRectangle(selection, plot);
23
23
  if (rectangle === null)
24
24
  return null;
25
- return (_jsx("rect", { x: rectangle.x, y: rectangle.y, width: rectangle.width, height: rectangle.height, pointerEvents: "none", style: selectionStyle }));
25
+ return (_jsx("rect", { "data-testid": "chart-selection", x: rectangle.x, y: rectangle.y, width: rectangle.width, height: rectangle.height, pointerEvents: "none", style: selectionStyle }));
26
26
  }
27
27
  const selectionStyle = {
28
28
  fill: CHART_COLORS.selection,
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionRect.js","sourceRoot":"","sources":["../../../src/chart/ui/SelectionRect.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA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EAAC,MAAM,EACpB,KAAK,EAAE,cAAc,GACrB,CACH,CAAC;AACJ,CAAC;AAED,MAAM,cAAc,GAAG;IACrB,IAAI,EAAE,YAAY,CAAC,SAAS;IAC5B,MAAM,EAAE,YAAY,CAAC,eAAe;CAC5B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-cheminfo",
3
- "version": "0.45.0",
3
+ "version": "0.46.0",
4
4
  "license": "MIT",
5
5
  "description": "React components, hooks and framework-free helpers shared by the cheminfo sites: site chrome, citations, sharing, routing, pedagogy, charts, and the structure, orbital and 3D molecule viewers",
6
6
  "author": "Luc Patiny",
@@ -80,18 +80,29 @@ export const DEFAULT_Y_AXIS_RULES: Required<YAxisRules> = {
80
80
  * between forty and sixty percent", so a drag narrows the horizontal axis and
81
81
  * leaves the height alone unless it is released past the baseline.
82
82
  *
83
+ * `dual` is the same reading gesture with a gate a reader can predict: a drag
84
+ * kept level narrows the horizontal axis alone, and one taken far enough up or
85
+ * down brings the height with it. It is what `xAxis` cannot be on a chart whose
86
+ * vertical axis has no baseline to cross — a titration curve climbing from pH 2
87
+ * to pH 12, a speciation diagram drawn over decades — where "has the pointer
88
+ * passed zero" is a question about the margin rather than about the data, and
89
+ * the answer to it is no for every drag made inside the plot. Here both windows
90
+ * are asked for where the curve is, and the preview changes shape as the
91
+ * threshold is crossed, so the rectangle is found by the hand that was already
92
+ * drawing one.
93
+ *
83
94
  * `box` is the tool: while it is chosen, the rectangle dragged out is the window,
84
95
  * both axes at once. It is a mode rather than a modifier because it is used in
85
96
  * runs — a baseline being examined is examined several times over — and a
86
97
  * modifier held down through each of them is a worse gesture than a tool pressed
87
98
  * once.
88
99
  *
89
- * The two are named apart from the whole of `DragMode` so that a chart offering
90
- * nothing but zoom tools can say so in its own signature — which is what stops
91
- * `select`, the one drag that moves no axis, from reaching a chart with no
92
- * handler for it.
100
+ * The three are named apart from the whole of `DragMode` so that a chart
101
+ * offering nothing but zoom tools can say so in its own signature — which is
102
+ * what stops `select`, the one drag that moves no axis, from reaching a chart
103
+ * with no handler for it.
93
104
  */
94
- export type ZoomDragMode = 'xAxis' | 'box';
105
+ export type ZoomDragMode = 'xAxis' | 'dual' | 'box';
95
106
 
96
107
  /**
97
108
  * What a drag across the plot asks for.
@@ -169,7 +169,9 @@ export {
169
169
  } from './viewTransform.ts';
170
170
  export type { DragBox, ZoomSelection } from './zoomDomain.ts';
171
171
  export {
172
+ DUAL_ZOOM_TRAVEL,
172
173
  MINIMUM_DRAG,
174
+ draggedBeyondLevel,
173
175
  releasedBeyondBaseline,
174
176
  scaledYAxis,
175
177
  zoomSelection,
@@ -34,9 +34,10 @@ export interface SelectionRectangle {
34
34
  * A drag that takes the y axis with it is drawn at the height of the drag
35
35
  * itself, and one that asks for the x axis alone spans the whole plot.
36
36
  * That is the gesture announcing itself before the button is let go: the
37
- * rectangle changing shape as the pointer crosses the baseline is the only
38
- * warning a user gets that the release is about to move both axes, and it is one
39
- * they can still act on.
37
+ * rectangle changing shape — as the pointer crosses the baseline, or as a
38
+ * `dual` drag leaves the level it started on — is the only warning a user gets
39
+ * that the release is about to move both axes, and it is one they can still act
40
+ * on.
40
41
  *
41
42
  * A drag too short to zoom draws nothing at all. Below `MINIMUM_DRAG` the
42
43
  * release does nothing — most clicks made on a trackpad wobble by a pixel or two
@@ -10,7 +10,7 @@
10
10
 
11
11
  import { clamp } from '../../format/core/clamp.ts';
12
12
 
13
- import type { ChartDomain, ZoomRules } from './chartDomain.ts';
13
+ import type { ChartDomain, DragMode, ZoomRules } from './chartDomain.ts';
14
14
  import { DEFAULT_Y_AXIS_RULES } from './chartDomain.ts';
15
15
  import type { PlotRect } from './chartGeometry.ts';
16
16
  import type { ChartScale } from './chartScale.ts';
@@ -30,6 +30,19 @@ import { chartPixel, chartValue } from './chartScale.ts';
30
30
  */
31
31
  export const MINIMUM_DRAG = 4;
32
32
 
33
+ /**
34
+ * How far a `dual` drag has to travel vertically before it brings the y axis
35
+ * with it, in user units of the SVG.
36
+ *
37
+ * Far enough above `MINIMUM_DRAG` that no drag meant to stay level reaches it by
38
+ * the tremor of a hand or the slope of a trackpad swipe, and near enough that
39
+ * the rectangle a reader wants costs one gesture rather than a reach for the
40
+ * margin. The preview changes shape on the pixel it is crossed, so the number
41
+ * itself never has to be learnt: the first drag that crosses it teaches the
42
+ * gesture, and the first that recrosses it back shows the way out.
43
+ */
44
+ export const DUAL_ZOOM_TRAVEL = 24;
45
+
33
46
  /** The two corners of a drag, in the user units of the SVG. */
34
47
  export interface DragBox {
35
48
  /** Where the press landed, horizontally. */
@@ -58,9 +71,9 @@ export interface ZoomSelection extends DragBox {
58
71
  * than by the rectangle itself — so what the preview promises and what letting
59
72
  * go actually does are the same test rather than two that have to agree.
60
73
  *
61
- * A `select` drag is therefore always a band, however far past the baseline it
62
- * strays: its answer is two numbers on one axis, so a preview that grew into a
63
- * rectangle would promise a height nobody is ever told about.
74
+ * Which answer a mode gives is `takesYAxis`'s business, so a `select` drag is
75
+ * always a band however far past the baseline it strays, and a `dual` drag
76
+ * becomes a rectangle the moment it has travelled `DUAL_ZOOM_TRAVEL`.
64
77
  * @param drag - The drag being made, `null` when none is.
65
78
  * @param yScale - The y axis as it is currently zoomed.
66
79
  * @param rules - How the y axis behaves and what a drag means, defaulting to a
@@ -83,16 +96,26 @@ export function zoomSelection(
83
96
  fromY: drag.fromY,
84
97
  toX: drag.toX,
85
98
  toY: drag.toY,
86
- // The box tool takes the height always, so the preview is a rectangle from
87
- // the first pixel of the gesture rather than a full-height band that
88
- // suddenly becomes one; a select drag never takes it at all.
89
- zoomsYAxis:
90
- mode === 'box' ||
91
- (mode !== 'select' &&
92
- releasedBeyondBaseline(drag.toY, yScale, baseline, pointsDown)),
99
+ zoomsYAxis: takesYAxis(drag, mode, yScale, baseline, pointsDown),
93
100
  };
94
101
  }
95
102
 
103
+ /**
104
+ * Whether a drag has left the level it started on by enough to ask for the y
105
+ * axis as well.
106
+ *
107
+ * Measured as the hand made it, before any clamping to the plot: a drag that ran
108
+ * out over the tick labels travelled however far it travelled. Nothing is
109
+ * latched — the answer is read off the two corners and nothing else — so a
110
+ * reader who drifted down and came back up is promised a band again, and the
111
+ * preview says so while the button is still down.
112
+ * @param drag - The drag being made or released, in user units of the SVG.
113
+ * @returns Whether the height comes along.
114
+ */
115
+ export function draggedBeyondLevel(drag: DragBox): boolean {
116
+ return Math.abs(drag.toY - drag.fromY) >= DUAL_ZOOM_TRAVEL;
117
+ }
118
+
96
119
  /**
97
120
  * Whether a drag let go here asks for the y axis as well.
98
121
  *
@@ -178,24 +201,19 @@ export function zoomedDomain(
178
201
  Math.min(firstX, secondX),
179
202
  Math.max(firstX, secondX),
180
203
  ];
181
- // The box tool is asked for the rectangle it was given, wherever it was let
182
- // go; the reading gesture takes the height only when it crossed the baseline.
183
- if (
184
- mode !== 'box' &&
185
- !releasedBeyondBaseline(drag.toY, yScale, baseline, pointsDown)
186
- ) {
204
+ if (!takesYAxis(drag, mode, yScale, baseline, pointsDown)) {
187
205
  return { x, y: current.y };
188
206
  }
189
207
 
190
208
  const fromY = chartValue(yScale, clamp(drag.fromY, plot.top, plot.bottom));
191
209
  const toY = chartValue(yScale, clamp(drag.toY, plot.top, plot.bottom));
192
210
  // Both ends, so a baseline the data runs *down* from — 100 percent
193
- // transmittance — is kept as surely as one it stands on. The box tool holds no
194
- // baseline at all: a rectangle dragged round a feature is a promise about
195
- // exactly that rectangle, and a viewer whose axis rules keep its baseline
196
- // would otherwise see the tool quietly return a taller window than the one
197
- // drawn.
198
- const holdBaseline = keepBaseline && mode !== 'box';
211
+ // transmittance — is kept as surely as one it stands on. Only the reading
212
+ // gesture holds a baseline: a rectangle dragged out deliberately, by the box
213
+ // tool or by a `dual` drag that left its level, is a promise about exactly
214
+ // that rectangle, and a viewer whose axis rules keep its baseline would
215
+ // otherwise see a taller window than the one drawn.
216
+ const holdBaseline = keepBaseline && mode === 'xAxis';
199
217
  const bottom = holdBaseline
200
218
  ? Math.min(baseline, fromY, toY)
201
219
  : Math.min(fromY, toY);
@@ -233,3 +251,36 @@ export function scaledYAxis(
233
251
  ];
234
252
  return y[1] > y[0] ? { x: current.x, y } : current;
235
253
  }
254
+
255
+ /**
256
+ * Whether a drag brings the y axis with it, which is the one question the
257
+ * preview and the release must never answer differently.
258
+ *
259
+ * Asked once, here, rather than by each of them: a rectangle that promises a
260
+ * height the release then refuses teaches a reader that the chart is
261
+ * unreliable, and two copies of this test are how that comes about.
262
+ *
263
+ * The box tool takes the height always, so its preview is a rectangle from the
264
+ * first pixel of the gesture rather than a full-height band that suddenly
265
+ * becomes one. A `select` drag never takes it at all: its answer is two numbers
266
+ * on one axis, and a preview that grew into a rectangle would promise a height
267
+ * nobody is ever told about.
268
+ * @param drag - The drag being made or released, in user units of the SVG.
269
+ * @param mode - What a drag on this chart asks for.
270
+ * @param yScale - The y axis as it is currently zoomed.
271
+ * @param baseline - The value the reading gesture is judged against.
272
+ * @param pointsDown - Whether the data hangs below that baseline.
273
+ * @returns Whether the height comes along.
274
+ */
275
+ function takesYAxis(
276
+ drag: DragBox,
277
+ mode: DragMode,
278
+ yScale: ChartScale,
279
+ baseline: number,
280
+ pointsDown: boolean,
281
+ ): boolean {
282
+ if (mode === 'box') return true;
283
+ if (mode === 'select') return false;
284
+ if (mode === 'dual') return draggedBeyondLevel(drag);
285
+ return releasedBeyondBaseline(drag.toY, yScale, baseline, pointsDown);
286
+ }
@@ -36,6 +36,10 @@ export function SelectionRect(props: SelectionRectProps): ReactElement | null {
36
36
 
37
37
  return (
38
38
  <rect
39
+ // Named, because the shape of this rectangle is the whole promise a drag
40
+ // makes — a band for the x axis alone, the drawn height for both — and
41
+ // the only way to check the promise is to measure it mid-drag.
42
+ data-testid="chart-selection"
39
43
  x={rectangle.x}
40
44
  y={rectangle.y}
41
45
  width={rectangle.width}