svelteplot 0.0.1-alpha.9 → 0.1.3-next.3
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/LICENSE.md +5 -0
- package/README.md +3 -36
- package/dist/Mark.svelte +292 -0
- package/dist/Mark.svelte.d.ts +22 -0
- package/dist/Plot.svelte +148 -156
- package/dist/Plot.svelte.d.ts +15 -15
- package/dist/constants.d.ts +14 -0
- package/dist/constants.js +109 -0
- package/dist/core/Facet.svelte +59 -0
- package/dist/core/Facet.svelte.d.ts +18 -0
- package/dist/core/FacetAxes.svelte +66 -0
- package/dist/core/FacetAxes.svelte.d.ts +4 -0
- package/dist/core/FacetGrid.svelte +86 -0
- package/dist/core/FacetGrid.svelte.d.ts +13 -0
- package/dist/core/Plot.svelte +567 -0
- package/dist/core/Plot.svelte.d.ts +14 -0
- package/dist/helpers/arrowPath.d.ts +14 -0
- package/dist/helpers/arrowPath.js +129 -0
- package/dist/helpers/autoProjection.d.ts +19 -0
- package/dist/helpers/autoProjection.js +87 -0
- package/dist/helpers/autoScales.d.ts +23 -0
- package/dist/helpers/autoScales.js +203 -0
- package/dist/helpers/autoTicks.d.ts +3 -0
- package/dist/helpers/autoTicks.js +40 -0
- package/dist/helpers/autoTimeFormat.d.ts +2 -2
- package/dist/helpers/autoTimeFormat.js +34 -5
- package/dist/helpers/callWithProps.d.ts +8 -0
- package/dist/helpers/callWithProps.js +13 -0
- package/dist/helpers/colors.js +17 -2
- package/dist/helpers/curves.d.ts +3 -0
- package/dist/helpers/curves.js +42 -0
- package/dist/helpers/data.d.ts +9 -0
- package/dist/helpers/data.js +16 -0
- package/dist/helpers/facets.d.ts +12 -0
- package/dist/helpers/facets.js +49 -0
- package/dist/helpers/formats.d.ts +3 -0
- package/dist/helpers/formats.js +3 -0
- package/dist/helpers/getBaseStyles.d.ts +7 -2
- package/dist/helpers/getBaseStyles.js +34 -10
- package/dist/helpers/getLogTicks.js +5 -5
- package/dist/helpers/group.d.ts +6 -0
- package/dist/helpers/group.js +53 -0
- package/dist/helpers/index.d.ts +18 -0
- package/dist/helpers/index.js +53 -0
- package/dist/helpers/isRawValue.d.ts +2 -0
- package/dist/helpers/isRawValue.js +5 -0
- package/dist/helpers/isValid.d.ts +6 -0
- package/dist/helpers/isValid.js +6 -0
- package/dist/helpers/math.d.ts +19 -0
- package/dist/helpers/math.js +116 -0
- package/dist/helpers/mergeDeep.d.ts +1 -1
- package/dist/helpers/noise.d.ts +1 -0
- package/dist/helpers/noise.js +72 -0
- package/dist/helpers/projection.d.ts +33 -0
- package/dist/helpers/projection.js +100 -0
- package/dist/helpers/reduce.d.ts +10 -0
- package/dist/helpers/reduce.js +85 -0
- package/dist/helpers/regressionLoess.d.ts +12 -0
- package/dist/helpers/regressionLoess.js +47 -0
- package/dist/helpers/removeIdenticalLines.d.ts +8 -1
- package/dist/helpers/removeIdenticalLines.js +14 -7
- package/dist/helpers/resolve.d.ts +17 -0
- package/dist/helpers/resolve.js +152 -0
- package/dist/helpers/roundedRect.d.ts +9 -0
- package/dist/helpers/roundedRect.js +31 -0
- package/dist/helpers/scales.d.ts +42 -0
- package/dist/helpers/scales.js +309 -0
- package/dist/helpers/time.d.ts +6 -0
- package/dist/helpers/time.js +282 -0
- package/dist/helpers/typeChecks.d.ts +8 -5
- package/dist/helpers/typeChecks.js +27 -6
- package/dist/index.d.ts +49 -1
- package/dist/index.js +53 -2
- package/dist/marks/Area.svelte +146 -0
- package/dist/marks/Area.svelte.d.ts +30 -0
- package/dist/marks/AreaX.svelte +27 -0
- package/dist/marks/AreaX.svelte.d.ts +12 -0
- package/dist/marks/AreaY.svelte +38 -0
- package/dist/marks/AreaY.svelte.d.ts +19 -0
- package/dist/marks/Arrow.svelte +139 -0
- package/dist/marks/Arrow.svelte.d.ts +44 -0
- package/dist/marks/AxisX.svelte +198 -93
- package/dist/marks/AxisX.svelte.d.ts +17 -16
- package/dist/marks/AxisY.svelte +176 -62
- package/dist/marks/AxisY.svelte.d.ts +17 -14
- package/dist/marks/BarX.svelte +81 -0
- package/dist/marks/BarX.svelte.d.ts +4 -0
- package/dist/marks/BarY.svelte +95 -0
- package/dist/marks/BarY.svelte.d.ts +4 -0
- package/dist/marks/BollingerX.svelte +44 -0
- package/dist/marks/BollingerX.svelte.d.ts +18 -0
- package/dist/marks/BollingerY.svelte +39 -0
- package/dist/marks/BollingerY.svelte.d.ts +18 -0
- package/dist/marks/BoxX.svelte +89 -0
- package/dist/marks/BoxX.svelte.d.ts +4 -0
- package/dist/marks/BoxY.svelte +110 -0
- package/dist/marks/BoxY.svelte.d.ts +29 -0
- package/dist/marks/Cell.svelte +110 -0
- package/dist/marks/Cell.svelte.d.ts +16 -0
- package/dist/marks/CellX.svelte +24 -0
- package/dist/marks/CellX.svelte.d.ts +3 -0
- package/dist/marks/CellY.svelte +24 -0
- package/dist/marks/CellY.svelte.d.ts +3 -0
- package/dist/marks/ColorLegend.svelte +148 -27
- package/dist/marks/ColorLegend.svelte.d.ts +12 -13
- package/dist/marks/CustomMark.svelte +43 -0
- package/dist/marks/CustomMark.svelte.d.ts +16 -0
- package/dist/marks/CustomMarkHTML.svelte +103 -0
- package/dist/marks/CustomMarkHTML.svelte.d.ts +17 -0
- package/dist/marks/DifferenceY.svelte +144 -0
- package/dist/marks/DifferenceY.svelte.d.ts +30 -0
- package/dist/marks/Dot.svelte +128 -73
- package/dist/marks/Dot.svelte.d.ts +24 -14
- package/dist/marks/DotX.svelte +15 -3
- package/dist/marks/DotX.svelte.d.ts +8 -16
- package/dist/marks/DotY.svelte +8 -3
- package/dist/marks/DotY.svelte.d.ts +5 -17
- package/dist/marks/Frame.svelte +32 -31
- package/dist/marks/Frame.svelte.d.ts +7 -14
- package/dist/marks/Geo.svelte +102 -0
- package/dist/marks/Geo.svelte.d.ts +10 -0
- package/dist/marks/Graticule.svelte +28 -0
- package/dist/marks/Graticule.svelte.d.ts +9 -0
- package/dist/marks/GridX.svelte +67 -36
- package/dist/marks/GridX.svelte.d.ts +7 -18
- package/dist/marks/GridY.svelte +64 -25
- package/dist/marks/GridY.svelte.d.ts +7 -14
- package/dist/marks/HTMLTooltip.svelte +91 -0
- package/dist/marks/HTMLTooltip.svelte.d.ts +11 -0
- package/dist/marks/Line.svelte +219 -58
- package/dist/marks/Line.svelte.d.ts +30 -14
- package/dist/marks/LineX.svelte +8 -8
- package/dist/marks/LineX.svelte.d.ts +4 -17
- package/dist/marks/LineY.svelte +7 -8
- package/dist/marks/LineY.svelte.d.ts +4 -17
- package/dist/marks/Link.svelte +173 -0
- package/dist/marks/Link.svelte.d.ts +21 -0
- package/dist/marks/Pointer.svelte +126 -0
- package/dist/marks/Pointer.svelte.d.ts +23 -0
- package/dist/marks/Rect.svelte +103 -0
- package/dist/marks/Rect.svelte.d.ts +15 -0
- package/dist/marks/RectX.svelte +33 -0
- package/dist/marks/RectX.svelte.d.ts +15 -0
- package/dist/marks/RectY.svelte +33 -0
- package/dist/marks/RectY.svelte.d.ts +15 -0
- package/dist/marks/RegressionX.svelte +26 -0
- package/dist/marks/RegressionX.svelte.d.ts +4 -0
- package/dist/marks/RegressionY.svelte +26 -0
- package/dist/marks/RegressionY.svelte.d.ts +4 -0
- package/dist/marks/RuleX.svelte +52 -28
- package/dist/marks/RuleX.svelte.d.ts +14 -14
- package/dist/marks/RuleY.svelte +52 -28
- package/dist/marks/RuleY.svelte.d.ts +14 -14
- package/dist/marks/Sphere.svelte +8 -0
- package/dist/marks/Sphere.svelte.d.ts +51 -0
- package/dist/marks/Spike.svelte +15 -0
- package/dist/marks/Spike.svelte.d.ts +4 -0
- package/dist/marks/SymbolLegend.svelte +27 -12
- package/dist/marks/SymbolLegend.svelte.d.ts +8 -14
- package/dist/marks/Text.svelte +185 -0
- package/dist/marks/Text.svelte.d.ts +26 -0
- package/dist/marks/TickX.svelte +89 -0
- package/dist/marks/TickX.svelte.d.ts +22 -0
- package/dist/marks/TickY.svelte +90 -0
- package/dist/marks/TickY.svelte.d.ts +22 -0
- package/dist/marks/Vector.svelte +213 -0
- package/dist/marks/Vector.svelte.d.ts +31 -0
- package/dist/marks/helpers/BaseAxisX.svelte +210 -0
- package/dist/marks/helpers/BaseAxisX.svelte.d.ts +24 -0
- package/dist/marks/helpers/BaseAxisY.svelte +187 -0
- package/dist/marks/helpers/BaseAxisY.svelte.d.ts +23 -0
- package/dist/marks/helpers/CanvasLayer.svelte +38 -0
- package/dist/marks/helpers/CanvasLayer.svelte.d.ts +13 -0
- package/dist/marks/helpers/DotCanvas.svelte +184 -0
- package/dist/marks/helpers/DotCanvas.svelte.d.ts +11 -0
- package/dist/marks/helpers/GeoCanvas.svelte +165 -0
- package/dist/marks/helpers/GeoCanvas.svelte.d.ts +13 -0
- package/dist/marks/helpers/GroupMultiple.svelte +17 -0
- package/dist/marks/helpers/GroupMultiple.svelte.d.ts +9 -0
- package/dist/marks/helpers/Marker.svelte +93 -0
- package/dist/marks/helpers/Marker.svelte.d.ts +10 -0
- package/dist/marks/helpers/MarkerPath.svelte +164 -0
- package/dist/marks/helpers/MarkerPath.svelte.d.ts +44 -0
- package/dist/marks/helpers/Regression.svelte +174 -0
- package/dist/marks/helpers/Regression.svelte.d.ts +26 -0
- package/dist/marks/helpers/events.d.ts +8 -0
- package/dist/marks/helpers/events.js +64 -0
- package/dist/transforms/bin.d.ts +51 -0
- package/dist/transforms/bin.js +171 -0
- package/dist/transforms/bollinger.d.ts +21 -0
- package/dist/transforms/bollinger.js +53 -0
- package/dist/transforms/centroid.d.ts +9 -0
- package/dist/transforms/centroid.js +13 -0
- package/dist/transforms/facet.d.ts +1 -0
- package/dist/transforms/facet.js +1 -0
- package/dist/transforms/filter.d.ts +2 -0
- package/dist/transforms/filter.js +8 -0
- package/dist/transforms/group.d.ts +66 -0
- package/dist/transforms/group.js +109 -0
- package/dist/transforms/interval.d.ts +11 -0
- package/dist/transforms/interval.js +34 -0
- package/dist/transforms/jitter.d.ts +0 -0
- package/dist/transforms/jitter.js +1 -0
- package/dist/transforms/map.d.ts +10 -0
- package/dist/transforms/map.js +89 -0
- package/dist/transforms/normalize.d.ts +9 -0
- package/dist/transforms/normalize.js +86 -0
- package/dist/transforms/recordize.d.ts +13 -0
- package/dist/transforms/recordize.js +75 -0
- package/dist/transforms/rename.d.ts +14 -0
- package/dist/transforms/rename.js +42 -0
- package/dist/transforms/select.d.ts +35 -0
- package/dist/transforms/select.js +55 -0
- package/dist/transforms/shift.d.ts +13 -0
- package/dist/transforms/shift.js +45 -0
- package/dist/transforms/sort.d.ts +28 -0
- package/dist/transforms/sort.js +61 -0
- package/dist/transforms/stack.d.ts +10 -0
- package/dist/transforms/stack.js +110 -0
- package/dist/transforms/window.d.ts +22 -0
- package/dist/transforms/window.js +73 -0
- package/dist/types.d.ts +625 -188
- package/dist/ui/Checkbox.svelte +6 -0
- package/dist/ui/Checkbox.svelte.d.ts +13 -0
- package/dist/ui/RadioInput.svelte +27 -0
- package/dist/ui/RadioInput.svelte.d.ts +9 -0
- package/dist/ui/Select.svelte +27 -0
- package/dist/ui/Select.svelte.d.ts +9 -0
- package/dist/ui/Slider.svelte +47 -0
- package/dist/ui/Slider.svelte.d.ts +11 -0
- package/dist/ui/Spiral.svelte +46 -0
- package/dist/ui/Spiral.svelte.d.ts +15 -0
- package/dist/ui/index.d.ts +4 -0
- package/dist/ui/index.js +4 -0
- package/package.json +79 -40
- package/LICENSE +0 -11
- package/dist/classes/Channel.svelte.js +0 -74
- package/dist/classes/Mark.svelte.js +0 -17
- package/dist/classes/Plot.svelte.js +0 -98
- package/dist/contants.d.ts +0 -3
- package/dist/contants.js +0 -40
- package/dist/helpers/GroupMultiple.svelte +0 -8
- package/dist/helpers/GroupMultiple.svelte.d.ts +0 -19
- package/dist/helpers/createScale.d.ts +0 -5
- package/dist/helpers/createScale.js +0 -57
- package/dist/helpers/resolveChannel.d.ts +0 -2
- package/dist/helpers/resolveChannel.js +0 -28
- package/dist/helpers/wrapArray.d.ts +0 -2
- package/dist/helpers/wrapArray.js +0 -4
- package/dist/marks/BaseMark.svelte +0 -22
- package/dist/marks/BaseMark.svelte.d.ts +0 -19
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { curveBasis, curveBasisClosed, curveBasisOpen, curveBundle, curveBumpX, curveBumpY, curveCardinal, curveCardinalClosed, curveCardinalOpen, curveCatmullRom, curveCatmullRomClosed, curveCatmullRomOpen, curveLinear, curveLinearClosed, curveMonotoneX, curveMonotoneY, curveNatural, curveStep, curveStepAfter, curveStepBefore } from 'd3-shape';
|
|
2
|
+
const curves = new Map([
|
|
3
|
+
['basis', curveBasis],
|
|
4
|
+
['basis-closed', curveBasisClosed],
|
|
5
|
+
['basis-open', curveBasisOpen],
|
|
6
|
+
['bundle', curveBundle],
|
|
7
|
+
['bump-x', curveBumpX],
|
|
8
|
+
['bump-y', curveBumpY],
|
|
9
|
+
['cardinal', curveCardinal],
|
|
10
|
+
['cardinal-closed', curveCardinalClosed],
|
|
11
|
+
['cardinal-open', curveCardinalOpen],
|
|
12
|
+
['catmull-rom', curveCatmullRom],
|
|
13
|
+
['catmull-rom-closed', curveCatmullRomClosed],
|
|
14
|
+
['catmull-rom-open', curveCatmullRomOpen],
|
|
15
|
+
['linear', curveLinear],
|
|
16
|
+
['linear-closed', curveLinearClosed],
|
|
17
|
+
['monotone-x', curveMonotoneX],
|
|
18
|
+
['monotone-y', curveMonotoneY],
|
|
19
|
+
['natural', curveNatural],
|
|
20
|
+
['step', curveStep],
|
|
21
|
+
['step-after', curveStepAfter],
|
|
22
|
+
['step-before', curveStepBefore]
|
|
23
|
+
]);
|
|
24
|
+
export function maybeCurve(curve = curveLinear, tension) {
|
|
25
|
+
if (typeof curve === 'function')
|
|
26
|
+
return curve; // custom curve
|
|
27
|
+
const c = curves.get(`${curve}`.toLowerCase());
|
|
28
|
+
if (!c)
|
|
29
|
+
throw new Error(`unknown curve: ${curve}`);
|
|
30
|
+
if (tension !== undefined) {
|
|
31
|
+
if ('beta' in c) {
|
|
32
|
+
return c.beta(tension);
|
|
33
|
+
}
|
|
34
|
+
else if ('tension' in c) {
|
|
35
|
+
return c.tension(tension);
|
|
36
|
+
}
|
|
37
|
+
else if ('alpha' in c) {
|
|
38
|
+
return c.alpha(tension);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return c;
|
|
42
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type Fetch = (input: RequestInfo, init?: RequestInit) => Promise<Response>;
|
|
2
|
+
export declare function loadJSON(fetch: Fetch, dataset: string): Promise<any>;
|
|
3
|
+
/**
|
|
4
|
+
* helper function used in the SveltePlot docs to load example datasets
|
|
5
|
+
*/
|
|
6
|
+
export declare function loadDatasets(ids: string[], fetch: Fetch): Promise<{
|
|
7
|
+
[key: string]: any[];
|
|
8
|
+
}>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { csvParse, autoType } from 'd3-dsv';
|
|
2
|
+
async function loadCSV(fetch, dataset) {
|
|
3
|
+
const res = await fetch(`/data/${dataset}.csv`);
|
|
4
|
+
const text = await res.text();
|
|
5
|
+
return csvParse(text, autoType);
|
|
6
|
+
}
|
|
7
|
+
export async function loadJSON(fetch, dataset) {
|
|
8
|
+
const res = await fetch(`/data/${dataset}.json`);
|
|
9
|
+
return await res.json();
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* helper function used in the SveltePlot docs to load example datasets
|
|
13
|
+
*/
|
|
14
|
+
export async function loadDatasets(ids, fetch) {
|
|
15
|
+
return Object.fromEntries((await Promise.all(ids.map((id) => loadCSV(fetch, id)))).map((data, i) => [ids[i], data]));
|
|
16
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { GenericMarkOptions, Mark, RawValue } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* This function tracks which facets are "empty", meaning that they don't contain
|
|
4
|
+
* any "facetted" data points. This can happen when fx and fy are combined and
|
|
5
|
+
* certain combinations don't yield results.
|
|
6
|
+
*
|
|
7
|
+
* @param marks
|
|
8
|
+
* @param fxValues x facet domain
|
|
9
|
+
* @param fyValues y facet domain
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
export declare function getEmptyFacets(marks: Mark<GenericMarkOptions>[], fxValues: RawValue[], fyValues: RawValue[]): Map<RawValue, Map<RawValue, boolean>>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { resolveChannel } from './resolve.js';
|
|
2
|
+
/**
|
|
3
|
+
* This function tracks which facets are "empty", meaning that they don't contain
|
|
4
|
+
* any "facetted" data points. This can happen when fx and fy are combined and
|
|
5
|
+
* certain combinations don't yield results.
|
|
6
|
+
*
|
|
7
|
+
* @param marks
|
|
8
|
+
* @param fxValues x facet domain
|
|
9
|
+
* @param fyValues y facet domain
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
export function getEmptyFacets(marks, fxValues, fyValues) {
|
|
13
|
+
const facettedMarks = marks.filter((mark) => {
|
|
14
|
+
return (mark.options.__firstFacet &&
|
|
15
|
+
mark.data.length > 0 && // has data
|
|
16
|
+
!mark.options.automatic && // not an automatic mark
|
|
17
|
+
(fxValues.length === 1 || mark.options.fx != null) && // uses x faceting
|
|
18
|
+
(fyValues.length === 1 || mark.options.fy != null) // uses y faceting
|
|
19
|
+
);
|
|
20
|
+
});
|
|
21
|
+
const facettedData = facettedMarks
|
|
22
|
+
.map((mark) => mark.data.map((datum) => {
|
|
23
|
+
const fx = resolveChannel('fx', datum, mark.options);
|
|
24
|
+
const fy = resolveChannel('fy', datum, mark.options);
|
|
25
|
+
return {
|
|
26
|
+
fx,
|
|
27
|
+
fy
|
|
28
|
+
};
|
|
29
|
+
}))
|
|
30
|
+
.flat(1);
|
|
31
|
+
const out = new Map();
|
|
32
|
+
for (const fx of fxValues) {
|
|
33
|
+
out.set(fx, new Map());
|
|
34
|
+
for (const fy of fyValues) {
|
|
35
|
+
// we need to loop over all facetted marks to see if there's any which has
|
|
36
|
+
// no data for the current fx,fy combination
|
|
37
|
+
let hasFacettedData = fxValues.length === 1 || fyValues.length === 1;
|
|
38
|
+
for (const datum of facettedData) {
|
|
39
|
+
if (datum.fx === fx && datum.fy === fy) {
|
|
40
|
+
hasFacettedData = true;
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
out.get(fx)?.set(fy, !hasFacettedData);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return out;
|
|
48
|
+
}
|
|
49
|
+
// TODO: write unit tests
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { Channels } from '../types.js';
|
|
2
|
+
import type { DataRow } from '../types.js';
|
|
3
|
+
export declare function getBaseStylesObject(datum: DataRow, props: Partial<Channels>): {
|
|
4
|
+
[k: string]: string | number;
|
|
5
|
+
};
|
|
6
|
+
export default function (datum: DataRow, props: Partial<Channels>): string;
|
|
7
|
+
export declare function maybeToPixel(cssKey: string, value: string | number): string | number;
|
|
@@ -1,18 +1,42 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { resolveProp } from './resolve.js';
|
|
2
|
+
/**
|
|
3
|
+
* all style props that can be applied via channels but
|
|
4
|
+
* are not scaled
|
|
5
|
+
*/
|
|
3
6
|
const styleProps = {
|
|
4
|
-
fill: 'fill',
|
|
5
|
-
stroke: 'stroke',
|
|
6
7
|
strokeWidth: 'stroke-width',
|
|
7
8
|
strokeDasharray: 'stroke-dasharray',
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
strokeLinejoin: 'stroke-linejoin',
|
|
10
|
+
strokeLinecap: 'stroke-linecap',
|
|
11
|
+
blend: 'mix-blend-mode',
|
|
12
|
+
clipPath: 'clip-path',
|
|
13
|
+
mask: 'mask',
|
|
10
14
|
fontSize: 'font-size',
|
|
11
|
-
|
|
15
|
+
fontWeight: 'font-weight',
|
|
16
|
+
fontStyle: 'font-style',
|
|
17
|
+
textAnchor: 'text-anchor',
|
|
18
|
+
cursor: 'cursor',
|
|
19
|
+
pointerEvents: 'pointer-events'
|
|
12
20
|
};
|
|
13
|
-
|
|
14
|
-
|
|
21
|
+
const styleDefaults = {
|
|
22
|
+
fontWeight: 'normal'
|
|
23
|
+
};
|
|
24
|
+
export function getBaseStylesObject(datum, props) {
|
|
25
|
+
return Object.fromEntries(Object.entries(styleProps)
|
|
15
26
|
.filter(([key, cssKey]) => cssKey && props[key] != null)
|
|
16
|
-
.map(([key, cssKey]) =>
|
|
27
|
+
.map(([key, cssKey]) => [
|
|
28
|
+
cssKey,
|
|
29
|
+
maybeToPixel(cssKey, resolveProp(props[key], datum, styleDefaults[key] || null))
|
|
30
|
+
]));
|
|
31
|
+
}
|
|
32
|
+
export default function (datum, props) {
|
|
33
|
+
return Object.entries(getBaseStylesObject(datum, props))
|
|
34
|
+
.map(([key, value]) => `${key}: ${value}`)
|
|
17
35
|
.join(';');
|
|
18
36
|
}
|
|
37
|
+
export function maybeToPixel(cssKey, value) {
|
|
38
|
+
if (cssKey === 'font-size' || cssKey === 'stroke-width') {
|
|
39
|
+
return typeof value === 'number' ? `${value}px` : value;
|
|
40
|
+
}
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
@@ -10,7 +10,7 @@ export function getLogTicks(domain, count = 6) {
|
|
|
10
10
|
return [];
|
|
11
11
|
if (domain[0] === 0)
|
|
12
12
|
return ticksArray(domain[0], domain[1], count - 2);
|
|
13
|
-
let mult = Math.pow(10, Math.floor(Math.log10(Math.abs(domain[1] - domain[0]))) - 1);
|
|
13
|
+
let mult = 1; //Math.pow(10, Math.floor(Math.log10(Math.abs(domain[1] - domain[0]))) - 1);
|
|
14
14
|
count += 2;
|
|
15
15
|
let candidates = getTickCandidates(domain, mult);
|
|
16
16
|
if (candidates[0].num > count) {
|
|
@@ -46,12 +46,12 @@ function getTickCandidates(domain, mult = 1) {
|
|
|
46
46
|
return logSeries.map((factors) => {
|
|
47
47
|
let i = Math.pow(10, Math.floor(Math.log10(domain[0])));
|
|
48
48
|
let f = 0;
|
|
49
|
-
const
|
|
50
|
-
while (i < domain[1] &&
|
|
49
|
+
const ticks = [i];
|
|
50
|
+
while (i < domain[1] && ticks.length < 50) {
|
|
51
51
|
i *= factors[f] * mult;
|
|
52
|
-
|
|
52
|
+
ticks.push(i);
|
|
53
53
|
f = (f + 1) % factors.length;
|
|
54
54
|
}
|
|
55
|
-
return { ticks
|
|
55
|
+
return { ticks, num: ticks.length };
|
|
56
56
|
});
|
|
57
57
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Channels, DataRecord } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Groups the data by the fx, fy and z channels and calls the reduce function
|
|
4
|
+
* for each group. Returns the new channels to be added in the transform.
|
|
5
|
+
*/
|
|
6
|
+
export declare function groupFacetsAndZ(items: DataRecord[], channels: Channels, reduce: (items: DataRecord[]) => any): any;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { resolveChannel } from './resolve.js';
|
|
2
|
+
import { groups as d3Groups } from 'd3-array';
|
|
3
|
+
/**
|
|
4
|
+
* Groups the data by the fx, fy and z channels and calls the reduce function
|
|
5
|
+
* for each group. Returns the new channels to be added in the transform.
|
|
6
|
+
*/
|
|
7
|
+
export function groupFacetsAndZ(items, channels, reduce) {
|
|
8
|
+
const groupBy = ['fx', 'fy', 'z'].map((groupChannel) => {
|
|
9
|
+
const groupByChannel = groupChannel === 'z'
|
|
10
|
+
? channels.z
|
|
11
|
+
? 'z'
|
|
12
|
+
: channels.fill
|
|
13
|
+
? 'fill'
|
|
14
|
+
: channels.stroke
|
|
15
|
+
? 'stroke'
|
|
16
|
+
: false
|
|
17
|
+
: channels[groupChannel]
|
|
18
|
+
? groupChannel
|
|
19
|
+
: false;
|
|
20
|
+
if (groupByChannel) {
|
|
21
|
+
const groupByPropName = typeof channels[groupByChannel] === 'string'
|
|
22
|
+
? channels[groupByChannel]
|
|
23
|
+
: `__group_${groupByChannel}`;
|
|
24
|
+
return [
|
|
25
|
+
groupByChannel,
|
|
26
|
+
groupByPropName,
|
|
27
|
+
(d) => resolveChannel(groupByChannel, d, channels)
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
return [null, null, () => true];
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
const groups = d3Groups(items, ...groupBy.map((d) => d[2]));
|
|
35
|
+
for (const [fxKey, fxGroups] of groups) {
|
|
36
|
+
const newItemGroupProps = {};
|
|
37
|
+
if (groupBy[0][0] !== null)
|
|
38
|
+
newItemGroupProps[groupBy[0][1]] = fxKey;
|
|
39
|
+
for (const [fyKey, fyGroups] of fxGroups) {
|
|
40
|
+
if (groupBy[1][0] !== null)
|
|
41
|
+
newItemGroupProps[groupBy[1][1]] = fyKey;
|
|
42
|
+
for (const [zKey, zGroups] of fyGroups) {
|
|
43
|
+
if (groupBy[2][0] !== null)
|
|
44
|
+
newItemGroupProps[groupBy[2][1]] = zKey;
|
|
45
|
+
reduce(zGroups, newItemGroupProps);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// return the new channel accessors to be added in the transform
|
|
50
|
+
return Object.fromEntries(groupBy
|
|
51
|
+
.filter(([groupByChannel]) => groupByChannel !== null)
|
|
52
|
+
.map(([groupByChannel, groupByProp]) => [groupByChannel, groupByProp]));
|
|
53
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ChannelAccessor, ChannelName, DataRecord, RawValue } from '../types.js';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
/**
|
|
4
|
+
* Returns first argument that is not null or undefined
|
|
5
|
+
*/
|
|
6
|
+
export declare function coalesce(...args: (RawValue | undefined | null)[]): RawValue | null;
|
|
7
|
+
export declare function testFilter(datum: DataRecord, options: Record<ChannelName, ChannelAccessor>): string | number | boolean | Date | null;
|
|
8
|
+
export declare function randomId(): string;
|
|
9
|
+
export declare function isSnippet(value: unknown): value is Snippet;
|
|
10
|
+
export declare function isValid(value: RawValue | undefined): value is number | Date | string;
|
|
11
|
+
export declare function maybeData(data: DataRecord[]): DataRecord[];
|
|
12
|
+
export declare function isObject(option: object | RawValue): option is object;
|
|
13
|
+
export declare function maybeNumber(value: RawValue | null): number | null;
|
|
14
|
+
export declare const constant: <T>(x: T) => () => T;
|
|
15
|
+
export declare const POSITION_CHANNELS: Set<ChannelName>;
|
|
16
|
+
export declare function parseInset(inset: number | string, width: number): number;
|
|
17
|
+
export declare function omit<T extends {}, K extends keyof T>(obj: T, ...keys: K[]): Omit<T, K>;
|
|
18
|
+
export declare function identity<T>(x: T): T;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { resolveProp } from './resolve.js';
|
|
2
|
+
import { isDate } from './typeChecks';
|
|
3
|
+
/**
|
|
4
|
+
* Returns first argument that is not null or undefined
|
|
5
|
+
*/
|
|
6
|
+
export function coalesce(...args) {
|
|
7
|
+
for (const arg of args) {
|
|
8
|
+
if (arg !== null && arg !== undefined) {
|
|
9
|
+
return arg;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return null; // Return null if all arguments are null or undefined
|
|
13
|
+
}
|
|
14
|
+
export function testFilter(datum, options) {
|
|
15
|
+
return options.filter == null || resolveProp(options.filter, datum);
|
|
16
|
+
}
|
|
17
|
+
export function randomId() {
|
|
18
|
+
return Math.ceil(1e9 + Math.random() * 1e9).toString(36);
|
|
19
|
+
}
|
|
20
|
+
export function isSnippet(value) {
|
|
21
|
+
return typeof value === 'function' && value.length === 1;
|
|
22
|
+
}
|
|
23
|
+
export function isValid(value) {
|
|
24
|
+
return value !== null && value !== undefined && !Number.isNaN(value);
|
|
25
|
+
}
|
|
26
|
+
export function maybeData(data) {
|
|
27
|
+
// if (data.type === 'FeatureCollection') return data.features;
|
|
28
|
+
return data;
|
|
29
|
+
}
|
|
30
|
+
export function isObject(option) {
|
|
31
|
+
// doesn't work with Proxies
|
|
32
|
+
return (typeof option === 'object' && !isDate(option) && !Array.isArray(option) && option !== null);
|
|
33
|
+
}
|
|
34
|
+
export function maybeNumber(value) {
|
|
35
|
+
return value != null ? +value : null;
|
|
36
|
+
}
|
|
37
|
+
export const constant = (x) => () => x;
|
|
38
|
+
export const POSITION_CHANNELS = new Set(['x', 'x1', 'x2', 'y', 'y1', 'y2']);
|
|
39
|
+
export function parseInset(inset, width) {
|
|
40
|
+
if (typeof inset === 'number') {
|
|
41
|
+
return inset;
|
|
42
|
+
}
|
|
43
|
+
if (inset.endsWith('%')) {
|
|
44
|
+
return (width * +inset.slice(0, -1)) / 100;
|
|
45
|
+
}
|
|
46
|
+
return +inset;
|
|
47
|
+
}
|
|
48
|
+
export function omit(obj, ...keys) {
|
|
49
|
+
return Object.fromEntries(Object.entries(obj).filter(([key]) => !keys.includes(key)));
|
|
50
|
+
}
|
|
51
|
+
export function identity(x) {
|
|
52
|
+
return x;
|
|
53
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Returns the normal deviate Z corresponding to a given lower tail area of P; Z is accurate to about 1 part in 10**16.
|
|
3
|
+
|
|
4
|
+
Wichura, M. J. (1988) Algorithm AS 241: The percentage points of the normal distribution. Applied Statistics, 37, 477–484.
|
|
5
|
+
|
|
6
|
+
extension of:
|
|
7
|
+
Beasley, J. D./ Springer, S. G. (1977), The percentage points of the NormalDistribution, Applied Statistics. 26, 118–121.
|
|
8
|
+
|
|
9
|
+
Excel: STANDNORMINV(); R: qnorm()
|
|
10
|
+
**/
|
|
11
|
+
export declare function normdev(p: number): number | false;
|
|
12
|
+
export declare function confidenceInterval(data: {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
}[], predict: any, confidenceLevel: number): (x: any) => {
|
|
16
|
+
x: any;
|
|
17
|
+
left: number;
|
|
18
|
+
right: any;
|
|
19
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { sum } from 'd3-array';
|
|
2
|
+
/**
|
|
3
|
+
Returns the normal deviate Z corresponding to a given lower tail area of P; Z is accurate to about 1 part in 10**16.
|
|
4
|
+
|
|
5
|
+
Wichura, M. J. (1988) Algorithm AS 241: The percentage points of the normal distribution. Applied Statistics, 37, 477–484.
|
|
6
|
+
|
|
7
|
+
extension of:
|
|
8
|
+
Beasley, J. D./ Springer, S. G. (1977), The percentage points of the NormalDistribution, Applied Statistics. 26, 118–121.
|
|
9
|
+
|
|
10
|
+
Excel: STANDNORMINV(); R: qnorm()
|
|
11
|
+
**/
|
|
12
|
+
export function normdev(p) {
|
|
13
|
+
if (p < 0 || p > 1)
|
|
14
|
+
return false;
|
|
15
|
+
if (p == 0)
|
|
16
|
+
return -Infinity;
|
|
17
|
+
if (p == 1)
|
|
18
|
+
return Infinity;
|
|
19
|
+
const a0 = 3.387132872796366608, a1 = 1.3314166789178437745e2, a2 = 1.9715909503065514427e3, a3 = 1.3731693765509461125e4, a4 = 4.5921953931549871457e4, a5 = 6.7265770927008700853e4, a6 = 3.3430575583588128105e4, a7 = 2.5090809287301226727e3, b1 = 4.2313330701600911252e1, b2 = 6.871870074920579083e2, b3 = 5.3941960214247511077e3, b4 = 2.1213794301586595867e4, b5 = 3.930789580009271061e4, b6 = 2.8729085735721942674e4, b7 = 5.226495278852854561e3, c0 = 1.42343711074968357734, c1 = 4.6303378461565452959, c2 = 5.7694972214606914055, c3 = 3.64784832476320460504, c4 = 1.27045825245236838258, c5 = 2.4178072517745061177e-1, c6 = 2.27238449892691845833e-2, c7 = 7.7454501427834140764e-4, d1 = 2.05319162663775882187, d2 = 1.6763848301838038494, d3 = 6.8976733498510000455e-1, d4 = 1.4810397642748007459e-1, d5 = 1.51986665636164571966e-2, d6 = 5.475938084995344946e-4, d7 = 1.05075007164441684324e-9, e0 = 6.6579046435011037772, e1 = 5.4637849111641143699, e2 = 1.7848265399172913358, e3 = 2.9656057182850489123e-1, e4 = 2.6532189526576123093e-2, e5 = 1.2426609473880784386e-3, e6 = 2.71155556874348757815e-5, e7 = 2.01033439929228813265e-7, f1 = 5.9983220655588793769e-1, f2 = 1.3692988092273580531e-1, f3 = 1.48753612908506148525e-2, f4 = 7.868691311456132591e-4, f5 = 1.8463183175100546818e-5, f6 = 1.4215117583164458887e-7, f7 = 2.04426310338993978564e-15;
|
|
20
|
+
const q = p - 0.5;
|
|
21
|
+
let r, z;
|
|
22
|
+
// p close to 0.5
|
|
23
|
+
if (Math.abs(q) <= 0.425) {
|
|
24
|
+
r = 0.180625 - q * q;
|
|
25
|
+
z =
|
|
26
|
+
(q * (((((((a7 * r + a6) * r + a5) * r + a4) * r + a3) * r + a2) * r + a1) * r + a0)) /
|
|
27
|
+
(((((((b7 * r + b6) * r + b5) * r + b4) * r + b3) * r + b2) * r + b1) * r + 1);
|
|
28
|
+
return z;
|
|
29
|
+
}
|
|
30
|
+
if (q > 0)
|
|
31
|
+
r = 1 - p;
|
|
32
|
+
else
|
|
33
|
+
r = p;
|
|
34
|
+
r = Math.sqrt(-Math.log(r));
|
|
35
|
+
// p neither close to 0.5 nor 0 or 1
|
|
36
|
+
if (r <= 5) {
|
|
37
|
+
r += -1.6;
|
|
38
|
+
z =
|
|
39
|
+
(((((((c7 * r + c6) * r + c5) * r + c4) * r + c3) * r + c2) * r + c1) * r + c0) /
|
|
40
|
+
(((((((d7 * r + d6) * r + d5) * r + d4) * r + d3) * r + d2) * r + d1) * r + 1);
|
|
41
|
+
}
|
|
42
|
+
// p near 0 or 1
|
|
43
|
+
else {
|
|
44
|
+
r += -5;
|
|
45
|
+
z =
|
|
46
|
+
(((((((e7 * r + e6) * r + e5) * r + e4) * r + e3) * r + e2) * r + e1) * r + e0) /
|
|
47
|
+
(((((((f7 * r + f6) * r + f5) * r + f4) * r + f3) * r + f2) * r + f1) * r + 1);
|
|
48
|
+
}
|
|
49
|
+
if (q < 0.0)
|
|
50
|
+
z = -z;
|
|
51
|
+
return z;
|
|
52
|
+
}
|
|
53
|
+
/*
|
|
54
|
+
Hill's approximated inverse t-distribution calculates t given df and two-tail probability:
|
|
55
|
+
Hill, G. W. (1970), Algorithm 396: Student's t-quantiles. Communications of the ACM, 13(10), 619–620.
|
|
56
|
+
|
|
57
|
+
Result should be "correct to at least 6 significant digits even for the analytic continuation through noninteger values of n > 5". For higher precision (used in R, ...) see:
|
|
58
|
+
Hill, G. W. (1981) Remark on Algorithm 396, ACM Transactions on Mathematical Software, 7, 250–1.
|
|
59
|
+
|
|
60
|
+
Excel: TINV(); R: qt()
|
|
61
|
+
*/
|
|
62
|
+
function inverseT(p, df) {
|
|
63
|
+
const { sin, cos, sqrt, pow, exp, PI } = Math;
|
|
64
|
+
// let a, b, c, d, t, x, y;
|
|
65
|
+
if (df == 1)
|
|
66
|
+
return cos((p * PI) / 2) / sin((p * PI) / 2);
|
|
67
|
+
if (df == 2)
|
|
68
|
+
return sqrt(2 / (p * (2 - p)) - 2);
|
|
69
|
+
const a = 1 / (df - 0.5);
|
|
70
|
+
const b = 48 / (a * a);
|
|
71
|
+
let c = (((20700 * a) / b - 98) * a - 16) * a + 96.36;
|
|
72
|
+
const d = ((94.5 / (b + c) - 3) / b + 1) * sqrt(a * PI * 0.5) * df;
|
|
73
|
+
let x = d * p;
|
|
74
|
+
let y = pow(x, 2 / df);
|
|
75
|
+
if (y > 0.05 + a) {
|
|
76
|
+
// The procedure normdev(p) is assumed to return a negative normal
|
|
77
|
+
// deviate at the lower tail probability level p, e.g. -2.32 for p = 0.01.
|
|
78
|
+
x = normdev(p / 2);
|
|
79
|
+
y = x * x;
|
|
80
|
+
if (df < 5)
|
|
81
|
+
c = c + 0.3 * (df - 4.5) * (x + 0.6);
|
|
82
|
+
c = (((0.05 * d * x - 5) * x - 7) * x - 2) * x + b + c;
|
|
83
|
+
y = (((((0.4 * y + 6.3) * y + 36) * y + 94.5) / c - y - 3) / b + 1) * x;
|
|
84
|
+
y = a * y * y;
|
|
85
|
+
if (y > 0.002)
|
|
86
|
+
y = exp(y) - 1;
|
|
87
|
+
else
|
|
88
|
+
y = 0.5 * y * y + y;
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
y =
|
|
92
|
+
(((1 / (((df + 6) / (df * y) - 0.089 * d - 0.822) * (df + 2) * 3) + 0.5 / (df + 4)) *
|
|
93
|
+
y -
|
|
94
|
+
1) *
|
|
95
|
+
(df + 1)) /
|
|
96
|
+
(df + 2) +
|
|
97
|
+
1 / y;
|
|
98
|
+
}
|
|
99
|
+
return sqrt(df * y);
|
|
100
|
+
}
|
|
101
|
+
// https://stats.stackexchange.com/questions/101318/understanding-shape-and-calculation-of-confidence-bands-in-linear-regression
|
|
102
|
+
export function confidenceInterval(data, predict, confidenceLevel) {
|
|
103
|
+
const mean = sum(data, (d) => d.x) / data.length;
|
|
104
|
+
let a = 0, b = 0;
|
|
105
|
+
for (let i = 0; i < data.length; ++i) {
|
|
106
|
+
a += Math.pow(data[i].x - mean, 2);
|
|
107
|
+
b += Math.pow(data[i].y - predict(data[i].x), 2);
|
|
108
|
+
}
|
|
109
|
+
const sy = Math.sqrt(b / (data.length - 2));
|
|
110
|
+
const t = inverseT(+confidenceLevel, data.length - 2);
|
|
111
|
+
return function (x) {
|
|
112
|
+
const Y = predict(x);
|
|
113
|
+
const se = sy * Math.sqrt(1 / data.length + Math.pow(x - mean, 2) / a);
|
|
114
|
+
return { x, left: Y - t * se, right: Y + t * se };
|
|
115
|
+
};
|
|
116
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function noise(x: number, y?: number, z?: number): number;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
const PERLIN_YWRAPB = 4;
|
|
2
|
+
const PERLIN_YWRAP = 1 << PERLIN_YWRAPB;
|
|
3
|
+
const PERLIN_ZWRAPB = 8;
|
|
4
|
+
const PERLIN_ZWRAP = 1 << PERLIN_ZWRAPB;
|
|
5
|
+
const PERLIN_SIZE = 4095;
|
|
6
|
+
let perlin_octaves = 4; // default to medium smooth
|
|
7
|
+
let perlin_amp_falloff = 0.5; // 50% reduction/octave
|
|
8
|
+
const scaled_cosine = (i) => 0.5 * (1.0 - Math.cos(i * Math.PI));
|
|
9
|
+
let perlin; // will be initialized lazily by noise() or noiseSeed()
|
|
10
|
+
export function noise(x, y = 0, z = 0) {
|
|
11
|
+
if (perlin == null) {
|
|
12
|
+
perlin = new Array(PERLIN_SIZE + 1);
|
|
13
|
+
for (let i = 0; i < PERLIN_SIZE + 1; i++) {
|
|
14
|
+
perlin[i] = Math.random();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
if (x < 0) {
|
|
18
|
+
x = -x;
|
|
19
|
+
}
|
|
20
|
+
if (y < 0) {
|
|
21
|
+
y = -y;
|
|
22
|
+
}
|
|
23
|
+
if (z < 0) {
|
|
24
|
+
z = -z;
|
|
25
|
+
}
|
|
26
|
+
let xi = Math.floor(x), yi = Math.floor(y), zi = Math.floor(z);
|
|
27
|
+
let xf = x - xi;
|
|
28
|
+
let yf = y - yi;
|
|
29
|
+
let zf = z - zi;
|
|
30
|
+
let rxf, ryf;
|
|
31
|
+
let r = 0;
|
|
32
|
+
let ampl = 0.5;
|
|
33
|
+
let n1, n2, n3;
|
|
34
|
+
for (let o = 0; o < perlin_octaves; o++) {
|
|
35
|
+
let of = xi + (yi << PERLIN_YWRAPB) + (zi << PERLIN_ZWRAPB);
|
|
36
|
+
rxf = scaled_cosine(xf);
|
|
37
|
+
ryf = scaled_cosine(yf);
|
|
38
|
+
n1 = perlin[of & PERLIN_SIZE];
|
|
39
|
+
n1 += rxf * (perlin[(of + 1) & PERLIN_SIZE] - n1);
|
|
40
|
+
n2 = perlin[(of + PERLIN_YWRAP) & PERLIN_SIZE];
|
|
41
|
+
n2 += rxf * (perlin[(of + PERLIN_YWRAP + 1) & PERLIN_SIZE] - n2);
|
|
42
|
+
n1 += ryf * (n2 - n1);
|
|
43
|
+
of += PERLIN_ZWRAP;
|
|
44
|
+
n2 = perlin[of & PERLIN_SIZE];
|
|
45
|
+
n2 += rxf * (perlin[(of + 1) & PERLIN_SIZE] - n2);
|
|
46
|
+
n3 = perlin[(of + PERLIN_YWRAP) & PERLIN_SIZE];
|
|
47
|
+
n3 += rxf * (perlin[(of + PERLIN_YWRAP + 1) & PERLIN_SIZE] - n3);
|
|
48
|
+
n2 += ryf * (n3 - n2);
|
|
49
|
+
n1 += scaled_cosine(zf) * (n2 - n1);
|
|
50
|
+
r += n1 * ampl;
|
|
51
|
+
ampl *= perlin_amp_falloff;
|
|
52
|
+
xi <<= 1;
|
|
53
|
+
xf *= 2;
|
|
54
|
+
yi <<= 1;
|
|
55
|
+
yf *= 2;
|
|
56
|
+
zi <<= 1;
|
|
57
|
+
zf *= 2;
|
|
58
|
+
if (xf >= 1.0) {
|
|
59
|
+
xi++;
|
|
60
|
+
xf--;
|
|
61
|
+
}
|
|
62
|
+
if (yf >= 1.0) {
|
|
63
|
+
yi++;
|
|
64
|
+
yf--;
|
|
65
|
+
}
|
|
66
|
+
if (zf >= 1.0) {
|
|
67
|
+
zi++;
|
|
68
|
+
zf--;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return r;
|
|
72
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
type Clip = boolean | null | number | 'frame';
|
|
2
|
+
type ProjectionOptions = {
|
|
3
|
+
type: string;
|
|
4
|
+
domain: number[];
|
|
5
|
+
inset: number;
|
|
6
|
+
insetTop: number;
|
|
7
|
+
insetBottom: number;
|
|
8
|
+
insetLeft: number;
|
|
9
|
+
insetRight: number;
|
|
10
|
+
clip: Clip;
|
|
11
|
+
stream: (a: number, b: number) => [number, number];
|
|
12
|
+
};
|
|
13
|
+
type Dimensions = {
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
marginTop: number;
|
|
17
|
+
marginBottom: number;
|
|
18
|
+
marginLeft: number;
|
|
19
|
+
marginRight: number;
|
|
20
|
+
};
|
|
21
|
+
export declare function createProjection({ projOptions, inset: globalInset, insetTop, insetRight, insetBottom, insetLeft }: {
|
|
22
|
+
projOptions?: ProjectionOptions | string;
|
|
23
|
+
inset?: number;
|
|
24
|
+
insetTop?: number;
|
|
25
|
+
insetRight?: number;
|
|
26
|
+
insetBottom?: number;
|
|
27
|
+
insetLeft?: number;
|
|
28
|
+
} | undefined, dimensions: Dimensions): string | ProjectionOptions | {
|
|
29
|
+
aspectRatio: number;
|
|
30
|
+
invert([x, y]: [any, any]): any;
|
|
31
|
+
stream: (s: any) => any;
|
|
32
|
+
} | undefined;
|
|
33
|
+
export {};
|