react-cheminfo 0.33.0 → 0.34.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.
- package/README.md +1 -1
- package/lib/axis/core/axisMarks.d.ts +54 -0
- package/lib/axis/core/axisMarks.d.ts.map +1 -0
- package/lib/axis/core/axisMarks.js +69 -0
- package/lib/axis/core/axisMarks.js.map +1 -0
- package/lib/axis/core/axisScale.d.ts +31 -0
- package/lib/axis/core/axisScale.d.ts.map +1 -0
- package/lib/axis/core/axisScale.js +31 -0
- package/lib/axis/core/axisScale.js.map +1 -0
- package/lib/axis/core/index.d.ts +16 -0
- package/lib/axis/core/index.d.ts.map +1 -0
- package/lib/axis/core/index.js +13 -0
- package/lib/axis/core/index.js.map +1 -0
- package/lib/axis/core/logAxisBounds.d.ts +78 -0
- package/lib/axis/core/logAxisBounds.d.ts.map +1 -0
- package/lib/axis/core/logAxisBounds.js +129 -0
- package/lib/axis/core/logAxisBounds.js.map +1 -0
- package/lib/axis/ui/AxisScaleControl.d.ts +66 -0
- package/lib/axis/ui/AxisScaleControl.d.ts.map +1 -0
- package/lib/axis/ui/AxisScaleControl.js +26 -0
- package/lib/axis/ui/AxisScaleControl.js.map +1 -0
- package/lib/axis/ui/index.d.ts +6 -0
- package/lib/axis/ui/index.d.ts.map +1 -0
- package/lib/axis/ui/index.js +5 -0
- package/lib/axis/ui/index.js.map +1 -0
- package/lib/core.d.ts +1 -0
- package/lib/core.d.ts.map +1 -1
- package/lib/core.js +1 -0
- package/lib/core.js.map +1 -1
- package/lib/delimited/core/index.d.ts +2 -0
- package/lib/delimited/core/index.d.ts.map +1 -1
- package/lib/delimited/core/index.js +1 -0
- package/lib/delimited/core/index.js.map +1 -1
- package/lib/delimited/core/tableRows.d.ts +49 -0
- package/lib/delimited/core/tableRows.d.ts.map +1 -0
- package/lib/delimited/core/tableRows.js +63 -0
- package/lib/delimited/core/tableRows.js.map +1 -0
- package/lib/delimited/ui/DelimitedTextPanel.d.ts +9 -0
- package/lib/delimited/ui/DelimitedTextPanel.d.ts.map +1 -1
- package/lib/delimited/ui/DelimitedTextPanel.js +3 -2
- package/lib/delimited/ui/DelimitedTextPanel.js.map +1 -1
- package/lib/delimited/ui/TableDataButton.d.ts +96 -0
- package/lib/delimited/ui/TableDataButton.d.ts.map +1 -0
- package/lib/delimited/ui/TableDataButton.js +39 -0
- package/lib/delimited/ui/TableDataButton.js.map +1 -0
- package/lib/delimited/ui/index.d.ts +2 -0
- package/lib/delimited/ui/index.d.ts.map +1 -1
- package/lib/delimited/ui/index.js +1 -0
- package/lib/delimited/ui/index.js.map +1 -1
- package/lib/i18n/core/chromeCatalog.d.ts +1 -1
- package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
- package/lib/locales/de.json +6 -0
- package/lib/locales/en.json +6 -0
- package/lib/locales/es.json +6 -0
- package/lib/locales/fr.json +6 -0
- package/lib/locales/it.json +6 -0
- package/lib/periodic/core/index.d.ts +1 -1
- package/lib/periodic/core/index.d.ts.map +1 -1
- package/lib/periodic/core/index.js +1 -1
- package/lib/periodic/core/index.js.map +1 -1
- package/lib/periodic/core/layout.d.ts +18 -0
- package/lib/periodic/core/layout.d.ts.map +1 -1
- package/lib/periodic/core/layout.js +9 -0
- package/lib/periodic/core/layout.js.map +1 -1
- package/lib/periodic/ui/ElementCell.js +15 -3
- package/lib/periodic/ui/ElementCell.js.map +1 -1
- package/lib/periodic/ui/PeriodicTable.d.ts +12 -1
- package/lib/periodic/ui/PeriodicTable.d.ts.map +1 -1
- package/lib/periodic/ui/PeriodicTable.js +25 -3
- package/lib/periodic/ui/PeriodicTable.js.map +1 -1
- package/lib/ui.d.ts +1 -0
- package/lib/ui.d.ts.map +1 -1
- package/lib/ui.js +1 -0
- package/lib/ui.js.map +1 -1
- package/package.json +1 -1
- package/src/axis/core/axisMarks.ts +114 -0
- package/src/axis/core/axisScale.ts +41 -0
- package/src/axis/core/index.ts +20 -0
- package/src/axis/core/logAxisBounds.ts +198 -0
- package/src/axis/ui/AxisScaleControl.tsx +103 -0
- package/src/axis/ui/index.ts +9 -0
- package/src/core.ts +1 -0
- package/src/delimited/core/index.ts +2 -0
- package/src/delimited/core/tableRows.ts +93 -0
- package/src/delimited/ui/DelimitedTextPanel.tsx +25 -9
- package/src/delimited/ui/TableDataButton.tsx +162 -0
- package/src/delimited/ui/index.ts +2 -0
- package/src/locales/de.json +6 -0
- package/src/locales/en.json +6 -0
- package/src/locales/es.json +6 -0
- package/src/locales/fr.json +6 -0
- package/src/locales/it.json +6 -0
- package/src/periodic/core/index.ts +1 -0
- package/src/periodic/core/layout.ts +19 -0
- package/src/periodic/ui/ElementCell.tsx +15 -3
- package/src/periodic/ui/PeriodicTable.tsx +45 -1
- package/src/ui.ts +1 -0
- package/styles/chrome.css +71 -0
package/README.md
CHANGED
|
@@ -112,7 +112,7 @@ through a wildcard subpath exactly as `react-science` serves its own.
|
|
|
112
112
|
| **Figures** | `chartScale`, `chartAxisScale`, `chartAxisTitle`, `chartShare`, `chartColumnExtent`, `chartBinCounts`, `chartSeriesColor`, `rowMatrix`, `stackedMatrix`, `emptiestCorner`, `placeOverlayCard`, `overlayMetrics` | `ChartFrame`, `ChartAxis`, `TrackedLineChart`, `OverlayBar`, `OverlaySelect`, `OverlaySegmented`, `OverlayToggle`, `OverlayNumber`, `OverlayLegend`, `OverlayCaption`, `OverlayReadout` |
|
|
113
113
|
| **Projections** | `pcaResult`, `embeddingResult`, `projectionTabs`, `loadingProfiles`, `explainedShares`, `confidenceEllipse`, `projectEllipse`, `pointsInPolygon`, `resolveProjectionGroups`, `resolveProjectionShapes`, `PROJECTION_COPY` | `PcaViewer`, `ProjectionViewer`, `ScatterPlot`, `ScatterMatrix` |
|
|
114
114
|
| **Parallel coordinates** | `parallelAxisOf`, `parallelAxisLayouts`, `parallelIncludedMask`, `parallelKeptCount`, `parallelNearestRow`, `parallelSegmentAt`, `parallelBandAt`, `parallelRangeOf`, `parallelPalette`, `parallelColorSteps`, `paintParallelLines` | `ParallelCoordinates` |
|
|
115
|
-
| **Periodic table** | `PERIODIC_ELEMENTS`, `elementBySymbol`, `elementByAtomicNumber`, `cellOf`, `placedElements`, `elementByArrowKey`, `categorySwatch`, `CATEGORY_LABELS`
|
|
115
|
+
| **Periodic table** | `PERIODIC_ELEMENTS`, `elementBySymbol`, `elementByAtomicNumber`, `cellOf`, `placedElements`, `elementByArrowKey`, `EMPTY_BLOCK`, `categorySwatch`, `CATEGORY_LABELS` | `PeriodicTable`, `ElementCell`, `CategoryLegend` |
|
|
116
116
|
|
|
117
117
|
Everything in that table is exported from `./core`, `./ui`, `./slides`,
|
|
118
118
|
`./vite` or `./structure` and nothing else is: the sub-components a component is built
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a figure's marks land inside its box, so something else can count them.
|
|
3
|
+
*
|
|
4
|
+
* `emptiestCorner` picks the corner a floating card can sit in without covering
|
|
5
|
+
* the cluster the reader came for, and it needs screen positions to do it. A
|
|
6
|
+
* chart drawn by a library builds its scales during its own render, where a
|
|
7
|
+
* caller cannot reach them, so the positions are worked out here from the same
|
|
8
|
+
* values and the same two transforms the axes use.
|
|
9
|
+
*
|
|
10
|
+
* It is an estimate, which is all a corner needs: the plot area is inset from
|
|
11
|
+
* the box by the margins, and a mark a few pixels from a corner counts for that
|
|
12
|
+
* corner either way.
|
|
13
|
+
*/
|
|
14
|
+
import type { AxisScale } from './axisScale.ts';
|
|
15
|
+
/** A point of the figure, in the quantities its axes carry. */
|
|
16
|
+
export interface AxisPoint {
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
}
|
|
20
|
+
/** Pixel positions of every mark, as `emptiestCorner` reads them. */
|
|
21
|
+
export interface AxisMarkPositions {
|
|
22
|
+
x: Float64Array;
|
|
23
|
+
y: Float64Array;
|
|
24
|
+
}
|
|
25
|
+
/** What {@link axisMarkPositions} needs beyond the points and the box. */
|
|
26
|
+
export interface AxisMarkPositionsOptions {
|
|
27
|
+
/**
|
|
28
|
+
* Width of the linear region of a logarithmic axis — d3's symmetric-log
|
|
29
|
+
* `constant`. Pass `0` for a true logarithmic axis.
|
|
30
|
+
* @default 1
|
|
31
|
+
*/
|
|
32
|
+
constant?: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Place every point in the box the figure is drawn in.
|
|
36
|
+
* @param points - The points the figure draws.
|
|
37
|
+
* @param box - Its size, in pixels, normally from `useContainerSize`.
|
|
38
|
+
* @param box.width - How wide the figure is drawn.
|
|
39
|
+
* @param box.height - How tall it is drawn.
|
|
40
|
+
* @param scale - The scale each axis is drawn on, which the positions have to
|
|
41
|
+
* follow to land where the marks do.
|
|
42
|
+
* @param scale.y - How the vertical axis is read.
|
|
43
|
+
* @param scale.x - How the horizontal axis is read.
|
|
44
|
+
* @param options - See {@link AxisMarkPositionsOptions}.
|
|
45
|
+
* @returns One position per point, in the order they were given.
|
|
46
|
+
*/
|
|
47
|
+
export declare function axisMarkPositions(points: readonly AxisPoint[], box: {
|
|
48
|
+
width: number;
|
|
49
|
+
height: number;
|
|
50
|
+
}, scale: {
|
|
51
|
+
x: AxisScale;
|
|
52
|
+
y: AxisScale;
|
|
53
|
+
}, options?: AxisMarkPositionsOptions): AxisMarkPositions;
|
|
54
|
+
//# sourceMappingURL=axisMarks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axisMarks.d.ts","sourceRoot":"","sources":["../../../src/axis/core/axisMarks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,+DAA+D;AAC/D,MAAM,WAAW,SAAS;IACxB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,qEAAqE;AACrE,MAAM,WAAW,iBAAiB;IAChC,CAAC,EAAE,YAAY,CAAC;IAChB,CAAC,EAAE,YAAY,CAAC;CACjB;AAED,0EAA0E;AAC1E,MAAM,WAAW,wBAAwB;IACvC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,SAAS,SAAS,EAAE,EAC5B,GAAG,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EACtC,KAAK,EAAE;IAAE,CAAC,EAAE,SAAS,CAAC;IAAC,CAAC,EAAE,SAAS,CAAA;CAAE,EACrC,OAAO,GAAE,wBAA6B,GACrC,iBAAiB,CAYnB"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a figure's marks land inside its box, so something else can count them.
|
|
3
|
+
*
|
|
4
|
+
* `emptiestCorner` picks the corner a floating card can sit in without covering
|
|
5
|
+
* the cluster the reader came for, and it needs screen positions to do it. A
|
|
6
|
+
* chart drawn by a library builds its scales during its own render, where a
|
|
7
|
+
* caller cannot reach them, so the positions are worked out here from the same
|
|
8
|
+
* values and the same two transforms the axes use.
|
|
9
|
+
*
|
|
10
|
+
* It is an estimate, which is all a corner needs: the plot area is inset from
|
|
11
|
+
* the box by the margins, and a mark a few pixels from a corner counts for that
|
|
12
|
+
* corner either way.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Place every point in the box the figure is drawn in.
|
|
16
|
+
* @param points - The points the figure draws.
|
|
17
|
+
* @param box - Its size, in pixels, normally from `useContainerSize`.
|
|
18
|
+
* @param box.width - How wide the figure is drawn.
|
|
19
|
+
* @param box.height - How tall it is drawn.
|
|
20
|
+
* @param scale - The scale each axis is drawn on, which the positions have to
|
|
21
|
+
* follow to land where the marks do.
|
|
22
|
+
* @param scale.y - How the vertical axis is read.
|
|
23
|
+
* @param scale.x - How the horizontal axis is read.
|
|
24
|
+
* @param options - See {@link AxisMarkPositionsOptions}.
|
|
25
|
+
* @returns One position per point, in the order they were given.
|
|
26
|
+
*/
|
|
27
|
+
export function axisMarkPositions(points, box, scale, options = {}) {
|
|
28
|
+
const { constant = 1 } = options;
|
|
29
|
+
const x = new Float64Array(points.length);
|
|
30
|
+
const y = new Float64Array(points.length);
|
|
31
|
+
place(points, 'x', scale.x === 'log', constant, box.width, x);
|
|
32
|
+
place(points, 'y', scale.y === 'log', constant, box.height, y);
|
|
33
|
+
// The vertical axis grows upwards while the box is measured from its top.
|
|
34
|
+
for (let index = 0; index < y.length; index++) {
|
|
35
|
+
y[index] = box.height - y[index];
|
|
36
|
+
}
|
|
37
|
+
return { x, y };
|
|
38
|
+
}
|
|
39
|
+
function place(points, axis, logarithmic, constant, extent, into) {
|
|
40
|
+
let min = Infinity;
|
|
41
|
+
let max = -Infinity;
|
|
42
|
+
for (let index = 0; index < points.length; index++) {
|
|
43
|
+
const value = transform(points[index][axis], logarithmic, constant);
|
|
44
|
+
into[index] = value;
|
|
45
|
+
if (value < min)
|
|
46
|
+
min = value;
|
|
47
|
+
if (value > max)
|
|
48
|
+
max = value;
|
|
49
|
+
}
|
|
50
|
+
const span = max - min;
|
|
51
|
+
for (let index = 0; index < into.length; index++) {
|
|
52
|
+
const value = into[index] - min;
|
|
53
|
+
into[index] = span === 0 ? extent / 2 : (value / span) * extent;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* d3's symmetric log, which is the one a genuine zero survives.
|
|
58
|
+
* @param value - The value to place.
|
|
59
|
+
* @param logarithmic - Whether the axis is read logarithmically at all.
|
|
60
|
+
* @param constant - Width of its linear region.
|
|
61
|
+
* @returns The value in the units the axis is spaced in.
|
|
62
|
+
*/
|
|
63
|
+
function transform(value, logarithmic, constant) {
|
|
64
|
+
if (!logarithmic)
|
|
65
|
+
return value;
|
|
66
|
+
const width = constant > 0 ? constant : 1;
|
|
67
|
+
return Math.sign(value) * Math.log1p(Math.abs(value) / width);
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=axisMarks.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every quantity has a scale it is usually read on — a concentration spanning
|
|
5
|
+
* ten decades is read logarithmically, a first ionisation energy linearly — and
|
|
6
|
+
* a reader may overrule it. The two are kept apart rather than collapsed into
|
|
7
|
+
* one boolean, because a figure that forgets which it is holding gets both of
|
|
8
|
+
* the following wrong: picking another quantity has to bring that quantity's
|
|
9
|
+
* own scale rather than carry the last one over, and a link has to stay silent
|
|
10
|
+
* about a scale nobody chose, so that it keeps opening the way the quantity is
|
|
11
|
+
* read even after the usual scale is reconsidered.
|
|
12
|
+
*/
|
|
13
|
+
/** The two scales an axis is drawn on. */
|
|
14
|
+
export type AxisScale = 'linear' | 'log';
|
|
15
|
+
/** A reader's choice, or `null` while they have not made one. */
|
|
16
|
+
export type AxisScaleChoice = AxisScale | null;
|
|
17
|
+
/**
|
|
18
|
+
* The scale an axis is actually drawn on.
|
|
19
|
+
* @param usual - How the quantity on the axis is normally read.
|
|
20
|
+
* @param chosen - What the reader asked for, or `null` to leave it to the
|
|
21
|
+
* quantity.
|
|
22
|
+
* @returns The scale to draw.
|
|
23
|
+
*/
|
|
24
|
+
export declare function resolveAxisScale(usual: AxisScale, chosen: AxisScaleChoice): AxisScale;
|
|
25
|
+
/**
|
|
26
|
+
* Narrow an arbitrary string — one off a query parameter — to a scale.
|
|
27
|
+
* @param value - Candidate scale.
|
|
28
|
+
* @returns True when it is one of the two.
|
|
29
|
+
*/
|
|
30
|
+
export declare function isAxisScale(value: string): value is AxisScale;
|
|
31
|
+
//# sourceMappingURL=axisScale.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axisScale.d.ts","sourceRoot":"","sources":["../../../src/axis/core/axisScale.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,0CAA0C;AAC1C,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,KAAK,CAAC;AAEzC,iEAAiE;AACjE,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,IAAI,CAAC;AAE/C;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,eAAe,GACtB,SAAS,CAEX;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,SAAS,CAE7D"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which of the two scales a quantity is read on, and who decided.
|
|
3
|
+
*
|
|
4
|
+
* Every quantity has a scale it is usually read on — a concentration spanning
|
|
5
|
+
* ten decades is read logarithmically, a first ionisation energy linearly — and
|
|
6
|
+
* a reader may overrule it. The two are kept apart rather than collapsed into
|
|
7
|
+
* one boolean, because a figure that forgets which it is holding gets both of
|
|
8
|
+
* the following wrong: picking another quantity has to bring that quantity's
|
|
9
|
+
* own scale rather than carry the last one over, and a link has to stay silent
|
|
10
|
+
* about a scale nobody chose, so that it keeps opening the way the quantity is
|
|
11
|
+
* read even after the usual scale is reconsidered.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* The scale an axis is actually drawn on.
|
|
15
|
+
* @param usual - How the quantity on the axis is normally read.
|
|
16
|
+
* @param chosen - What the reader asked for, or `null` to leave it to the
|
|
17
|
+
* quantity.
|
|
18
|
+
* @returns The scale to draw.
|
|
19
|
+
*/
|
|
20
|
+
export function resolveAxisScale(usual, chosen) {
|
|
21
|
+
return chosen ?? usual;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Narrow an arbitrary string — one off a query parameter — to a scale.
|
|
25
|
+
* @param value - Candidate scale.
|
|
26
|
+
* @returns True when it is one of the two.
|
|
27
|
+
*/
|
|
28
|
+
export function isAxisScale(value) {
|
|
29
|
+
return value === 'linear' || value === 'log';
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=axisScale.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axisScale.js","sourceRoot":"","sources":["../../../src/axis/core/axisScale.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAQH;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAC9B,KAAgB,EAChB,MAAuB;IAEvB,OAAO,MAAM,IAAI,KAAK,CAAC;AACzB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,KAAa;IACvC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,KAAK,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How an axis is read: linearly or logarithmically, who decided, where it
|
|
3
|
+
* starts and ends, and where its marks land.
|
|
4
|
+
*
|
|
5
|
+
* It is a domain of its own rather than part of any chart, because the library
|
|
6
|
+
* draws figures with three different renderers and the sites draw more with
|
|
7
|
+
* libraries of their own — and the two things that go wrong on a logarithmic
|
|
8
|
+
* axis go wrong the same way in all of them.
|
|
9
|
+
*/
|
|
10
|
+
export type { AxisMarkPositions, AxisMarkPositionsOptions, AxisPoint, } from './axisMarks.ts';
|
|
11
|
+
export { axisMarkPositions } from './axisMarks.ts';
|
|
12
|
+
export type { AxisScale, AxisScaleChoice } from './axisScale.ts';
|
|
13
|
+
export { isAxisScale, resolveAxisScale } from './axisScale.ts';
|
|
14
|
+
export type { LogAxisBounds, LogAxisBoundsOptions } from './logAxisBounds.ts';
|
|
15
|
+
export { logAxisBounds } from './logAxisBounds.ts';
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/axis/core/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,YAAY,EACV,iBAAiB,EACjB,wBAAwB,EACxB,SAAS,GACV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC/D,YAAY,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How an axis is read: linearly or logarithmically, who decided, where it
|
|
3
|
+
* starts and ends, and where its marks land.
|
|
4
|
+
*
|
|
5
|
+
* It is a domain of its own rather than part of any chart, because the library
|
|
6
|
+
* draws figures with three different renderers and the sites draw more with
|
|
7
|
+
* libraries of their own — and the two things that go wrong on a logarithmic
|
|
8
|
+
* axis go wrong the same way in all of them.
|
|
9
|
+
*/
|
|
10
|
+
export { axisMarkPositions } from "./axisMarks.js";
|
|
11
|
+
export { isAxisScale, resolveAxisScale } from "./axisScale.js";
|
|
12
|
+
export { logAxisBounds } from "./logAxisBounds.js";
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/axis/core/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAOH,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAE/D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ends of a logarithmic axis, and the values it is graduated at.
|
|
3
|
+
*
|
|
4
|
+
* Both have to be stated rather than left to the charting library, and for two
|
|
5
|
+
* separate reasons.
|
|
6
|
+
*
|
|
7
|
+
* The ends, because a library that finds them itself may not look at every
|
|
8
|
+
* value. nivo is the measured case: it sorts and takes a true minimum and
|
|
9
|
+
* maximum only for a linear axis, and on a log or symmetric-log one `'auto'`
|
|
10
|
+
* resolves to the first value the data carries and the last — so the domain
|
|
11
|
+
* comes out in plotting order, upside down whenever the first point outweighs
|
|
12
|
+
* the last, and cutting off everything past the last point drawn.
|
|
13
|
+
*
|
|
14
|
+
* The graduations, because d3 rules a symmetric-log axis at evenly *spaced*
|
|
15
|
+
* values while placing them logarithmically, so the top of a wide axis collects
|
|
16
|
+
* every graduation it has into one unreadable line. Ruling it by decade spreads
|
|
17
|
+
* them evenly, which is also how such a quantity is read.
|
|
18
|
+
*/
|
|
19
|
+
/** What {@link logAxisBounds} answers. */
|
|
20
|
+
export interface LogAxisBounds {
|
|
21
|
+
/** The low end of the axis. */
|
|
22
|
+
min: number;
|
|
23
|
+
/** The high end. */
|
|
24
|
+
max: number;
|
|
25
|
+
/**
|
|
26
|
+
* The values to rule it at, or `undefined` for an axis spanning too few
|
|
27
|
+
* decades to be worth ruling by them — there the library's own linear
|
|
28
|
+
* graduations read better, and there is no pile-up to undo.
|
|
29
|
+
*/
|
|
30
|
+
tickValues?: number[];
|
|
31
|
+
}
|
|
32
|
+
/** What {@link logAxisBounds} needs beyond the values. */
|
|
33
|
+
export interface LogAxisBoundsOptions {
|
|
34
|
+
/**
|
|
35
|
+
* Width of the linear region at the bottom of a symmetric-log axis — d3's
|
|
36
|
+
* `constant`. Everything smaller than it is placed almost on the zero line,
|
|
37
|
+
* so no graduation is written below it; a graduation there would land on top
|
|
38
|
+
* of the one before it, which is the pile-up this exists to prevent.
|
|
39
|
+
*
|
|
40
|
+
* Pass `0` for a true logarithmic axis, which has no such region — and which
|
|
41
|
+
* cannot place a zero or a negative at all, so those values are then left out
|
|
42
|
+
* of the ends rather than dragging them to nothing.
|
|
43
|
+
* @default 1
|
|
44
|
+
*/
|
|
45
|
+
constant?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Whether the ends are rounded outwards to whole powers of ten. An axis that
|
|
48
|
+
* ends on its own extreme values reads as though those were round numbers;
|
|
49
|
+
* one that ends on decades says what it is. Worth it on a true logarithmic
|
|
50
|
+
* axis, where every graduation is a decade anyway.
|
|
51
|
+
* @default false — the ends are the data's own
|
|
52
|
+
*/
|
|
53
|
+
snapToDecades?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* How many decades the axis may span at most, counted down from its top. A
|
|
56
|
+
* quantity that reaches zero asymptotically has no meaningful bottom, and an
|
|
57
|
+
* axis given one spends most of its height on values nobody is reading.
|
|
58
|
+
* Only consulted with `snapToDecades`.
|
|
59
|
+
* @default Infinity — the axis spans whatever the data does
|
|
60
|
+
*/
|
|
61
|
+
maxDecades?: number;
|
|
62
|
+
/**
|
|
63
|
+
* How many graduations the axis may carry. More than this is a smear however
|
|
64
|
+
* they are spread, so the decades are stepped over rather than written out.
|
|
65
|
+
* @default 10
|
|
66
|
+
*/
|
|
67
|
+
mostTicks?: number;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Where a logarithmic axis starts and ends, and where it is graduated.
|
|
71
|
+
* @param values - Every value plotted on the axis. Anything not finite is
|
|
72
|
+
* ignored, so a sheet's gaps need not be filtered out first.
|
|
73
|
+
* @param options - See {@link LogAxisBoundsOptions}.
|
|
74
|
+
* @returns The ends and the graduations, or `null` when no value can be drawn
|
|
75
|
+
* and the caller should leave the axis to its library.
|
|
76
|
+
*/
|
|
77
|
+
export declare function logAxisBounds(values: Iterable<number>, options?: LogAxisBoundsOptions): LogAxisBounds | null;
|
|
78
|
+
//# sourceMappingURL=logAxisBounds.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logAxisBounds.d.ts","sourceRoot":"","sources":["../../../src/axis/core/logAxisBounds.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,0CAA0C;AAC1C,MAAM,WAAW,aAAa;IAC5B,+BAA+B;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,oBAAoB;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,0DAA0D;AAC1D,MAAM,WAAW,oBAAoB;IACnC;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAKD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,EACxB,OAAO,GAAE,oBAAyB,GACjC,aAAa,GAAG,IAAI,CAkCtB"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ends of a logarithmic axis, and the values it is graduated at.
|
|
3
|
+
*
|
|
4
|
+
* Both have to be stated rather than left to the charting library, and for two
|
|
5
|
+
* separate reasons.
|
|
6
|
+
*
|
|
7
|
+
* The ends, because a library that finds them itself may not look at every
|
|
8
|
+
* value. nivo is the measured case: it sorts and takes a true minimum and
|
|
9
|
+
* maximum only for a linear axis, and on a log or symmetric-log one `'auto'`
|
|
10
|
+
* resolves to the first value the data carries and the last — so the domain
|
|
11
|
+
* comes out in plotting order, upside down whenever the first point outweighs
|
|
12
|
+
* the last, and cutting off everything past the last point drawn.
|
|
13
|
+
*
|
|
14
|
+
* The graduations, because d3 rules a symmetric-log axis at evenly *spaced*
|
|
15
|
+
* values while placing them logarithmically, so the top of a wide axis collects
|
|
16
|
+
* every graduation it has into one unreadable line. Ruling it by decade spreads
|
|
17
|
+
* them evenly, which is also how such a quantity is read.
|
|
18
|
+
*/
|
|
19
|
+
/** Under this many decades the library's own graduations read better. */
|
|
20
|
+
const RULE_PAST_DECADES = 3;
|
|
21
|
+
/**
|
|
22
|
+
* Where a logarithmic axis starts and ends, and where it is graduated.
|
|
23
|
+
* @param values - Every value plotted on the axis. Anything not finite is
|
|
24
|
+
* ignored, so a sheet's gaps need not be filtered out first.
|
|
25
|
+
* @param options - See {@link LogAxisBoundsOptions}.
|
|
26
|
+
* @returns The ends and the graduations, or `null` when no value can be drawn
|
|
27
|
+
* and the caller should leave the axis to its library.
|
|
28
|
+
*/
|
|
29
|
+
export function logAxisBounds(values, options = {}) {
|
|
30
|
+
const { constant = 1, snapToDecades = false } = options;
|
|
31
|
+
const { maxDecades = Infinity, mostTicks = 10 } = options;
|
|
32
|
+
// A true logarithmic axis has no room for a zero or a negative, so they are
|
|
33
|
+
// not what its bottom end is taken from.
|
|
34
|
+
const positiveOnly = constant === 0;
|
|
35
|
+
let min = Infinity;
|
|
36
|
+
let max = -Infinity;
|
|
37
|
+
for (const value of values) {
|
|
38
|
+
if (!Number.isFinite(value))
|
|
39
|
+
continue;
|
|
40
|
+
if (positiveOnly && value <= 0)
|
|
41
|
+
continue;
|
|
42
|
+
if (value < min)
|
|
43
|
+
min = value;
|
|
44
|
+
if (value > max)
|
|
45
|
+
max = value;
|
|
46
|
+
}
|
|
47
|
+
if (min > max)
|
|
48
|
+
return null;
|
|
49
|
+
if (snapToDecades) {
|
|
50
|
+
const top = Math.ceil(Math.log10(Math.abs(max) || 1));
|
|
51
|
+
const bottom = Math.max(Math.floor(Math.log10(Math.abs(min) || 1)), top - maxDecades);
|
|
52
|
+
return withTicks(decade(bottom), decade(top), constant, mostTicks);
|
|
53
|
+
}
|
|
54
|
+
// A lone value, or a column of identical ones, spans nothing: reach to the
|
|
55
|
+
// origin so it is read against a zero rather than filling the axis.
|
|
56
|
+
if (min === max) {
|
|
57
|
+
if (min === 0)
|
|
58
|
+
return { min: -1, max: 1 };
|
|
59
|
+
return { min: Math.min(min, 0), max: Math.max(max, 0) };
|
|
60
|
+
}
|
|
61
|
+
return withTicks(min, max, constant, mostTicks);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The ends, with the graduations when they are worth writing.
|
|
65
|
+
* @param min
|
|
66
|
+
* @param max
|
|
67
|
+
* @param constant
|
|
68
|
+
* @param mostTicks
|
|
69
|
+
*/
|
|
70
|
+
function withTicks(min, max, constant, mostTicks) {
|
|
71
|
+
const ticks = decadesBetween(min, max, constant, mostTicks);
|
|
72
|
+
return ticks === undefined ? { min, max } : { min, max, tickValues: ticks };
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Zero, and the powers of ten the axis both reaches and can separate.
|
|
76
|
+
* @param min - The low end of the axis.
|
|
77
|
+
* @param max - Its high end.
|
|
78
|
+
* @param constant - Width of the linear region; see the options.
|
|
79
|
+
* @param mostTicks - How many graduations the axis may carry.
|
|
80
|
+
* @returns The values to rule it at, or nothing to leave it to the library.
|
|
81
|
+
*/
|
|
82
|
+
function decadesBetween(min, max, constant, mostTicks) {
|
|
83
|
+
const largest = Math.max(Math.abs(min), Math.abs(max));
|
|
84
|
+
if (largest === 0)
|
|
85
|
+
return undefined;
|
|
86
|
+
// Below the linear region every decade lands on the same pixel, so the axis
|
|
87
|
+
// is ruled from there up rather than from its smallest value.
|
|
88
|
+
const floor = constant > 0 ? Math.log10(constant) : smallestDecade(min, max);
|
|
89
|
+
const bottom = Math.ceil(floor);
|
|
90
|
+
const top = Math.floor(Math.log10(largest));
|
|
91
|
+
// Under a few decades the library's own graduations read better — but only
|
|
92
|
+
// where it has linear ones to offer. On a true logarithmic axis every
|
|
93
|
+
// graduation is a decade, so a short one is still ruled by decade.
|
|
94
|
+
if (constant > 0 && top - bottom + 1 < RULE_PAST_DECADES)
|
|
95
|
+
return undefined;
|
|
96
|
+
const step = Math.ceil((top - bottom + 1) / mostTicks);
|
|
97
|
+
const ticks = min <= 0 && max >= 0 ? [0] : [];
|
|
98
|
+
for (let power = bottom; power <= top; power += step) {
|
|
99
|
+
const tick = decade(power);
|
|
100
|
+
if (tick >= min && tick <= max)
|
|
101
|
+
ticks.push(tick);
|
|
102
|
+
}
|
|
103
|
+
if (constant === 0)
|
|
104
|
+
return ticks;
|
|
105
|
+
return ticks.length < RULE_PAST_DECADES ? undefined : ticks;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* A whole power of ten.
|
|
109
|
+
* @param power - The exponent, a whole number.
|
|
110
|
+
* @returns Ten to that power, the same bits on every engine.
|
|
111
|
+
*/
|
|
112
|
+
function decade(power) {
|
|
113
|
+
// Read as a decimal rather than computed: `10 ** power` goes through pow,
|
|
114
|
+
// which is not bit-exact across V8 versions — node 22 answers
|
|
115
|
+
// 0.00009999999999999999 for -4 and 1.0000000000000001e-20 for -20 — while a
|
|
116
|
+
// decimal literal is the correctly-rounded double everywhere.
|
|
117
|
+
return Number(`1e${power}`);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* The decade of the smaller end, for an axis with no linear region.
|
|
121
|
+
* @param min - The low end of the axis.
|
|
122
|
+
* @param max - Its high end.
|
|
123
|
+
* @returns The base-ten logarithm of the smaller end that is not zero.
|
|
124
|
+
*/
|
|
125
|
+
function smallestDecade(min, max) {
|
|
126
|
+
const ends = [Math.abs(min), Math.abs(max)].filter((end) => end > 0);
|
|
127
|
+
return Math.log10(Math.min(...ends));
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=logAxisBounds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logAxisBounds.js","sourceRoot":"","sources":["../../../src/axis/core/logAxisBounds.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAsDH,yEAAyE;AACzE,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAE5B;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAC3B,MAAwB,EACxB,UAAgC,EAAE;IAElC,MAAM,EAAE,QAAQ,GAAG,CAAC,EAAE,aAAa,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;IACxD,MAAM,EAAE,UAAU,GAAG,QAAQ,EAAE,SAAS,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC;IAC1D,4EAA4E;IAC5E,yCAAyC;IACzC,MAAM,YAAY,GAAG,QAAQ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CAAC,CAAC,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The control that moves one axis between its two scales.
|
|
3
|
+
*
|
|
4
|
+
* It belongs on the figure rather than in the page around it: the scale is not
|
|
5
|
+
* a property of the page but of the picture, a reader decides to change it
|
|
6
|
+
* while looking at the picture, and a figure handed out on its own — embedded
|
|
7
|
+
* in a course page, pasted into a deck — takes its controls with it. So it is
|
|
8
|
+
* written as a control of an `OverlayBar`, floating in whichever corner the
|
|
9
|
+
* marks leave emptiest.
|
|
10
|
+
*
|
|
11
|
+
* Its two segments are named here rather than by each site, because `Linear`
|
|
12
|
+
* and `Log` are chrome: one translation reaches every figure in the family.
|
|
13
|
+
*/
|
|
14
|
+
import type { ReactElement } from 'react';
|
|
15
|
+
import type { HelpContent } from '../../help/ui/HelpBody.tsx';
|
|
16
|
+
import type { AxisScale } from '../core/axisScale.ts';
|
|
17
|
+
/** Which axis a control belongs to, which is how it names itself. */
|
|
18
|
+
export type AxisScaleAxis = 'x' | 'y';
|
|
19
|
+
/** What {@link AxisScaleControl} needs. */
|
|
20
|
+
export interface AxisScaleControlProps {
|
|
21
|
+
/** The scale in force — what `resolveAxisScale` answered, not the choice. */
|
|
22
|
+
value: AxisScale;
|
|
23
|
+
/** Called with the scale the reader picked. */
|
|
24
|
+
onChange: (scale: AxisScale) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Which axis it sets, which names it `X scale` or `Y scale`. Leave it out on
|
|
27
|
+
* a figure where only one axis offers the choice: the control is then simply
|
|
28
|
+
* `Scale`, because naming the axis is only worth the width when there are two
|
|
29
|
+
* of them to tell apart.
|
|
30
|
+
* @default undefined — the control is named `Scale`
|
|
31
|
+
*/
|
|
32
|
+
axis?: AxisScaleAxis;
|
|
33
|
+
/**
|
|
34
|
+
* What it is called, overriding both of the above. For a figure whose axis
|
|
35
|
+
* has a name the reader already knows it by.
|
|
36
|
+
* @default the chrome's own word, in the language of the page
|
|
37
|
+
*/
|
|
38
|
+
label?: string;
|
|
39
|
+
/**
|
|
40
|
+
* What the two scales do, in a sentence.
|
|
41
|
+
* @default the chrome's own explanation
|
|
42
|
+
*/
|
|
43
|
+
help?: HelpContent;
|
|
44
|
+
/**
|
|
45
|
+
* Whether the name is announced but not written.
|
|
46
|
+
* @default false
|
|
47
|
+
*/
|
|
48
|
+
hideLabel?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Whether the control is greyed and unreachable.
|
|
51
|
+
* @default false
|
|
52
|
+
*/
|
|
53
|
+
disabled?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Value of the `data-testid` attribute.
|
|
56
|
+
* @default undefined
|
|
57
|
+
*/
|
|
58
|
+
testId?: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The two scales, the one in force pressed.
|
|
62
|
+
* @param props - See {@link AxisScaleControlProps}.
|
|
63
|
+
* @returns The named pair of segments.
|
|
64
|
+
*/
|
|
65
|
+
export declare function AxisScaleControl(props: AxisScaleControlProps): ReactElement;
|
|
66
|
+
//# sourceMappingURL=AxisScaleControl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AxisScaleControl.d.ts","sourceRoot":"","sources":["../../../src/axis/ui/AxisScaleControl.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAI9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,qEAAqE;AACrE,MAAM,MAAM,aAAa,GAAG,GAAG,GAAG,GAAG,CAAC;AAEtC,2CAA2C;AAC3C,MAAM,WAAW,qBAAqB;IACpC,6EAA6E;IAC7E,KAAK,EAAE,SAAS,CAAC;IACjB,+CAA+C;IAC/C,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;IACrC;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,YAAY,CAsB3E"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useChromeT } from "../../i18n/ui/useT.js";
|
|
3
|
+
import { OverlaySegmented } from "../../overlay/ui/OverlaySegmented.js";
|
|
4
|
+
/**
|
|
5
|
+
* The two scales, the one in force pressed.
|
|
6
|
+
* @param props - See {@link AxisScaleControlProps}.
|
|
7
|
+
* @returns The named pair of segments.
|
|
8
|
+
*/
|
|
9
|
+
export function AxisScaleControl(props) {
|
|
10
|
+
const { value, onChange, axis, label, help, testId } = props;
|
|
11
|
+
const { hideLabel = false, disabled = false } = props;
|
|
12
|
+
const t = useChromeT();
|
|
13
|
+
const options = [
|
|
14
|
+
{ value: 'linear', label: t('axis.linear') },
|
|
15
|
+
{ value: 'log', label: t('axis.logarithmic') },
|
|
16
|
+
];
|
|
17
|
+
return (_jsx(OverlaySegmented, { label: label ?? t(nameOf(axis)), help: help ?? { title: t('axis.scale'), body: t('axis.scaleHelp') }, hideLabel: hideLabel, disabled: disabled, value: value, options: options, onChange: onChange, testId: testId }));
|
|
18
|
+
}
|
|
19
|
+
function nameOf(axis) {
|
|
20
|
+
if (axis === 'x')
|
|
21
|
+
return 'axis.xScale';
|
|
22
|
+
if (axis === 'y')
|
|
23
|
+
return 'axis.yScale';
|
|
24
|
+
return 'axis.scale';
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=AxisScaleControl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AxisScaleControl.js","sourceRoot":"","sources":["../../../src/axis/ui/AxisScaleControl.tsx"],"names":[],"mappings":";AAiBA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAuC,CAAC;AAgDzE;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAA4B;IAC3D,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IAC7D,MAAM,EAAE,SAAS,GAAG,KAAK,EAAE,QAAQ,GAAG,KAAK,EAAE,GAAG,KAAK,CAAC;IACtD,MAAM,CAAC,GAAG,UAAU,EAAE,CAAC;IAEvB,MAAM,OAAO,GAA4C;QACvD,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,aAAa,CAAC,EAAE;QAC5C,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,kBAAkB,CAAC,EAAE;KAC/C,CAAC;IAEF,OAAO,CACL,KAAC,gBAAgB,IACf,KAAK,EAAE,KAAK,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAC/B,IAAI,EAAE,IAAI,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,gBAAgB,CAAC,EAAE,EACnE,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,GACd,CACH,CAAC;AACJ,CAAC;AAED,SAAS,MAAM,CACb,IAA+B;IAE/B,IAAI,IAAI,KAAK,GAAG;QAAE,OAAO,aAAa,CAAC;IACvC,IAAI,IAAI,KAAK,GAAG;QAAE,OAAO,aAAa,CAAC;IACvC,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/axis/ui/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,YAAY,EACV,aAAa,EACb,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/axis/ui/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAwB,CAAC"}
|
package/lib/core.d.ts
CHANGED
package/lib/core.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,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AwB,CAAC;AACvC,cAAc,wBAAwB,CAAC"}
|
package/lib/core.js
CHANGED
package/lib/core.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,+EAA+E;AAC/E,2EAA2E;AAC3E,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,0EAA0E;AAC1E,8EAA8E;AAC9E,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CA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