svelteplot 0.2.6-next.1 → 0.2.6-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/dist/core/Facet.svelte +1 -2
- package/dist/core/FacetGrid.svelte +1 -1
- package/dist/core/Plot.svelte +2 -1
- package/dist/helpers/autoScales.js +16 -2
- package/dist/helpers/projection.js +1 -1
- package/dist/helpers/reduce.js +1 -1
- package/dist/helpers/resolve.js +0 -1
- package/dist/helpers/scales.js +1 -1
- package/dist/marks/Arrow.svelte +0 -1
- package/dist/marks/AxisY.svelte +0 -2
- package/dist/marks/CellX.svelte +1 -1
- package/dist/marks/ColorLegend.svelte +1 -1
- package/dist/marks/DifferenceY.svelte +0 -1
- package/dist/marks/Dot.svelte +1 -1
- package/dist/marks/Geo.svelte +1 -3
- package/dist/marks/GridY.svelte +1 -1
- package/dist/marks/Line.svelte +2 -2
- package/dist/marks/Line.svelte.d.ts +1 -1
- package/dist/marks/Rect.svelte +0 -3
- package/dist/marks/helpers/BaseAxisY.svelte +1 -1
- package/dist/marks/helpers/DotCanvas.svelte +0 -1
- package/dist/marks/helpers/GeoCanvas.svelte +1 -1
- package/dist/marks/helpers/events.js +1 -1
- package/dist/transforms/bin.js +2 -2
- package/dist/transforms/window.js +1 -1
- package/dist/types.d.ts +4 -0
- package/package.json +1 -1
package/dist/core/Facet.svelte
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { setContext, type Snippet } from 'svelte';
|
|
3
3
|
import { resolveChannel } from '../helpers/resolve.js';
|
|
4
|
-
import type { BaseMarkProps, DataRecord,
|
|
5
|
-
import { identity } from '../helpers';
|
|
4
|
+
import type { BaseMarkProps, DataRecord, RawValue } from '../types.js';
|
|
6
5
|
|
|
7
6
|
let {
|
|
8
7
|
fx,
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
marks for each facet domain value
|
|
5
5
|
-->
|
|
6
6
|
<script lang="ts">
|
|
7
|
-
import { getContext,
|
|
7
|
+
import { getContext, type Snippet } from 'svelte';
|
|
8
8
|
import type { PlotContext, GenericMarkOptions, Mark } from '../types.js';
|
|
9
9
|
import { scaleBand } from 'd3-scale';
|
|
10
10
|
import Facet from './Facet.svelte';
|
package/dist/core/Plot.svelte
CHANGED
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
initialWidth: 500,
|
|
63
63
|
inset: 0,
|
|
64
64
|
colorScheme: 'turbo',
|
|
65
|
+
unknown: '#cccccc',
|
|
65
66
|
dotRadius: 3,
|
|
66
67
|
frame: false,
|
|
67
68
|
axes: true,
|
|
@@ -160,7 +161,7 @@
|
|
|
160
161
|
);
|
|
161
162
|
|
|
162
163
|
// if the plot is showing filled dot marks we're using different defaults
|
|
163
|
-
// for the symbol axis range, so we're passing on this info to the
|
|
164
|
+
// for the symbol axis range, so we're passing on this info to the computeScales
|
|
164
165
|
// function below
|
|
165
166
|
const hasFilledDotMarks = $derived(
|
|
166
167
|
!!explicitMarks.find((d) => d.type === 'dot' && d.options.fill)
|
|
@@ -5,6 +5,7 @@ import callWithProps from './callWithProps.js';
|
|
|
5
5
|
import { interpolateLab, interpolateRound } from 'd3-interpolate';
|
|
6
6
|
import { coalesce, maybeNumber } from './index.js';
|
|
7
7
|
import { getLogTicks } from './getLogTicks.js';
|
|
8
|
+
import { isPlainObject } from 'es-toolkit';
|
|
8
9
|
const Scales = {
|
|
9
10
|
point: scalePoint,
|
|
10
11
|
band: scaleBand,
|
|
@@ -102,10 +103,23 @@ export function autoScaleColor({ type, domain, scaleOptions, plotOptions, plotWi
|
|
|
102
103
|
let fn;
|
|
103
104
|
let range;
|
|
104
105
|
// special treatment for color scales
|
|
105
|
-
const { scheme, interpolate, pivot, n = type === 'threshold' ? domain.length + 1 : 9 } = scaleOptions;
|
|
106
|
+
const { scheme, interpolate, pivot, n = type === 'threshold' ? domain.length + 1 : 9, unknown = plotDefaults.unknown } = scaleOptions;
|
|
106
107
|
if (type === 'categorical' || type === 'ordinal') {
|
|
107
108
|
// categorical
|
|
108
|
-
|
|
109
|
+
let scheme_ = scheme || plotDefaults.categoricalColorScheme;
|
|
110
|
+
if (isPlainObject(scheme_)) {
|
|
111
|
+
const newScheme = Object.values(scheme_);
|
|
112
|
+
const newDomain = Object.keys(scheme_);
|
|
113
|
+
// for every value in domain that's not part of the scheme, map to unknown
|
|
114
|
+
for (const v of domain) {
|
|
115
|
+
if (scheme_[v] == null) {
|
|
116
|
+
newDomain.push(v);
|
|
117
|
+
newScheme.push(unknown);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
domain = newDomain;
|
|
121
|
+
scheme_ = newScheme;
|
|
122
|
+
}
|
|
109
123
|
// categorical scale
|
|
110
124
|
range = Array.isArray(scheme_)
|
|
111
125
|
? scheme_
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { geoClipRectangle, geoPath, geoTransform } from 'd3-geo';
|
|
2
|
-
import { constant, isObject
|
|
2
|
+
import { constant, isObject } from './index.js';
|
|
3
3
|
const identity = constant({ stream: (stream) => stream });
|
|
4
4
|
const defaultAspectRatio = 0.618;
|
|
5
5
|
export function createProjection({ projOptions, inset: globalInset = 2, insetTop = globalInset, insetRight = globalInset, insetBottom = globalInset, insetLeft = globalInset } = {}, dimensions) {
|
package/dist/helpers/reduce.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { min, max, mode, sum, mean, median, variance, deviation, quantile
|
|
1
|
+
import { min, max, mode, sum, mean, median, variance, deviation, quantile } from 'd3-array';
|
|
2
2
|
import { resolveChannel } from './resolve.js';
|
|
3
3
|
import { POSITION_CHANNELS } from './index.js';
|
|
4
4
|
const niceReduceNames = {
|
package/dist/helpers/resolve.js
CHANGED
|
@@ -2,7 +2,6 @@ import { CHANNEL_SCALE } from '../constants.js';
|
|
|
2
2
|
import isDataRecord from './isDataRecord.js';
|
|
3
3
|
import isRawValue from './isRawValue.js';
|
|
4
4
|
import { isValid } from './isValid.js';
|
|
5
|
-
import { pick } from 'es-toolkit';
|
|
6
5
|
import { getBaseStylesObject } from './getBaseStyles.js';
|
|
7
6
|
import { RAW_VALUE } from '../transforms/recordize.js';
|
|
8
7
|
export function resolveProp(accessor, datum, _defaultValue = null) {
|
package/dist/helpers/scales.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { extent,
|
|
1
|
+
import { extent, ascending } from 'd3-array';
|
|
2
2
|
import { isColorOrNull, isDateOrNull, isNumberOrNull, isNumberOrNullOrNaN, isStringOrNull } from './typeChecks.js';
|
|
3
3
|
import { CHANNEL_SCALE, VALID_SCALE_TYPES } from '../constants.js';
|
|
4
4
|
import { isSymbolOrNull } from './typeChecks.js';
|
package/dist/marks/Arrow.svelte
CHANGED
package/dist/marks/AxisY.svelte
CHANGED
|
@@ -6,11 +6,9 @@
|
|
|
6
6
|
PlotContext,
|
|
7
7
|
BaseMarkProps,
|
|
8
8
|
RawValue,
|
|
9
|
-
DataRecord,
|
|
10
9
|
FacetContext,
|
|
11
10
|
DefaultOptions
|
|
12
11
|
} from '../types.js';
|
|
13
|
-
import getBaseStyles from '../helpers/getBaseStyles.js';
|
|
14
12
|
import autoTimeFormat from '../helpers/autoTimeFormat.js';
|
|
15
13
|
import type { ConstantAccessor } from '../types.js';
|
|
16
14
|
import { autoTicks } from '../helpers/autoTicks.js';
|
package/dist/marks/CellX.svelte
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import Cell from './Cell.svelte';
|
|
3
|
-
import {
|
|
3
|
+
import { recordizeY } from '../index.js';
|
|
4
4
|
import type { BaseMarkProps, DataRow, RectMarkProps } from '../types.js';
|
|
5
5
|
import type { ChannelAccessor } from '../types.js';
|
|
6
6
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { getContext } from 'svelte';
|
|
3
3
|
import { Plot, AxisX, Frame } from '../index.js';
|
|
4
|
-
import { symbol as d3Symbol
|
|
4
|
+
import { symbol as d3Symbol } from 'd3-shape';
|
|
5
5
|
import { range as d3Range, extent } from 'd3-array';
|
|
6
6
|
import { maybeSymbol } from '../helpers/symbols.js';
|
|
7
7
|
|
package/dist/marks/Dot.svelte
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
import { sort } from '../index.js';
|
|
16
16
|
import Mark from '../Mark.svelte';
|
|
17
17
|
import DotCanvas from './helpers/DotCanvas.svelte';
|
|
18
|
-
import { maybeData,
|
|
18
|
+
import { maybeData, isValid } from '../helpers/index.js';
|
|
19
19
|
import { recordizeXY } from '../transforms/recordize.js';
|
|
20
20
|
import { addEventHandlers } from './helpers/events.js';
|
|
21
21
|
|
package/dist/marks/Geo.svelte
CHANGED
package/dist/marks/GridY.svelte
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { getContext } from 'svelte';
|
|
3
3
|
import Mark from '../Mark.svelte';
|
|
4
|
-
import type { PlotContext, BaseMarkProps, RawValue
|
|
4
|
+
import type { PlotContext, BaseMarkProps, RawValue } from '../types.js';
|
|
5
5
|
import { resolveChannel, resolveStyles } from '../helpers/resolve.js';
|
|
6
6
|
import { autoTicks } from '../helpers/autoTicks.js';
|
|
7
7
|
import { testFilter } from '../helpers/index.js';
|
package/dist/marks/Line.svelte
CHANGED
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
import MarkerPath from './helpers/MarkerPath.svelte';
|
|
42
42
|
import { getContext } from 'svelte';
|
|
43
43
|
import { resolveProp, resolveStyles } from '../helpers/resolve.js';
|
|
44
|
-
import { line, type CurveFactory, type Line } from 'd3-shape';
|
|
44
|
+
import { line, type CurveFactory, type Line as D3Line } from 'd3-shape';
|
|
45
45
|
import { geoPath } from 'd3-geo';
|
|
46
46
|
import callWithProps from '../helpers/callWithProps.js';
|
|
47
47
|
import { maybeCurve } from '../helpers/curves.js';
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
101
101
|
const plot = $derived(getPlotState());
|
|
102
102
|
|
|
103
|
-
const linePath:
|
|
103
|
+
const linePath: D3Line<ScaledDataRecord> = $derived(
|
|
104
104
|
plot.scales.projection && curve === 'auto'
|
|
105
105
|
? sphereLine(plot.scales.projection)
|
|
106
106
|
: callWithProps(line, [], {
|
|
@@ -21,7 +21,7 @@ export type BaseLineMarkProps = {
|
|
|
21
21
|
lineClass?: ConstantAccessor<string>;
|
|
22
22
|
canvas?: boolean;
|
|
23
23
|
} & MarkerOptions;
|
|
24
|
-
import { type CurveFactory
|
|
24
|
+
import { type CurveFactory } from 'd3-shape';
|
|
25
25
|
import type { RawValue } from '../types.js';
|
|
26
26
|
type LineMarkProps = BaseMarkProps & {
|
|
27
27
|
x?: ChannelAccessor;
|
package/dist/marks/Rect.svelte
CHANGED
|
@@ -6,8 +6,6 @@
|
|
|
6
6
|
import Mark from '../Mark.svelte';
|
|
7
7
|
import { getContext } from 'svelte';
|
|
8
8
|
import { intervalX, intervalY } from '../index.js';
|
|
9
|
-
import { resolveProp, resolveStyles } from '../helpers/resolve.js';
|
|
10
|
-
import { coalesce, maybeNumber } from '../helpers/index.js';
|
|
11
9
|
import type {
|
|
12
10
|
PlotContext,
|
|
13
11
|
DataRecord,
|
|
@@ -15,7 +13,6 @@
|
|
|
15
13
|
BaseRectMarkProps,
|
|
16
14
|
ChannelAccessor
|
|
17
15
|
} from '../types.js';
|
|
18
|
-
import { addEventHandlers } from './helpers/events.js';
|
|
19
16
|
import GroupMultiple from './helpers/GroupMultiple.svelte';
|
|
20
17
|
import RectPath from './helpers/RectPath.svelte';
|
|
21
18
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { getContext,
|
|
2
|
+
import { getContext, untrack } from 'svelte';
|
|
3
3
|
import { randomId, testFilter } from '../../helpers/index.js';
|
|
4
4
|
import { resolveProp, resolveStyles } from '../../helpers/resolve.js';
|
|
5
5
|
import { max } from 'd3-array';
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
ScaledDataRecord,
|
|
7
7
|
PlotContext
|
|
8
8
|
} from '../../types.js';
|
|
9
|
-
import { CSS_VAR } from '../../constants.js';
|
|
10
9
|
import { resolveProp } from '../../helpers/resolve.js';
|
|
11
10
|
import { maybeSymbol } from '../../helpers/symbols.js';
|
|
12
11
|
import { symbol as d3Symbol } from 'd3-shape';
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
} from '../../types.js';
|
|
9
9
|
import { CSS_VAR } from '../../constants.js';
|
|
10
10
|
import { resolveProp, resolveScaledStyleProps } from '../../helpers/resolve.js';
|
|
11
|
-
import { getContext
|
|
11
|
+
import { getContext } from 'svelte';
|
|
12
12
|
import { type GeoPath } from 'd3-geo';
|
|
13
13
|
import CanvasLayer from './CanvasLayer.svelte';
|
|
14
14
|
import type { Attachment } from 'svelte/attachments';
|
package/dist/transforms/bin.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { resolveChannel } from '../helpers/resolve.js';
|
|
2
2
|
import { maybeInterval } from '../helpers/autoTicks.js';
|
|
3
|
-
import { bin as d3Bin, extent,
|
|
4
|
-
import {
|
|
3
|
+
import { bin as d3Bin, extent, thresholdFreedmanDiaconis, thresholdScott, thresholdSturges } from 'd3-array';
|
|
4
|
+
import { reduceOutputs } from '../helpers/reduce.js';
|
|
5
5
|
import { groupFacetsAndZ } from '../helpers/group.js';
|
|
6
6
|
import { isDate } from '../helpers/typeChecks.js';
|
|
7
7
|
const ThresholdGenerators = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { maybeInterval } from '../helpers/autoTicks.js';
|
|
2
2
|
import { isValid } from '../helpers/index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { mayberReducer } from '../helpers/reduce.js';
|
|
4
4
|
import { resolveChannel } from '../helpers/resolve.js';
|
|
5
5
|
import { groups as d3Groups } from 'd3-array';
|
|
6
6
|
export function windowX(args, options) {
|
package/dist/types.d.ts
CHANGED
|
@@ -339,6 +339,10 @@ export type PlotDefaults = {
|
|
|
339
339
|
*/
|
|
340
340
|
numberFormat: Intl.NumberFormatOptions;
|
|
341
341
|
markerDotRadius: number;
|
|
342
|
+
/**
|
|
343
|
+
* fallback color to be used for null/NA
|
|
344
|
+
*/
|
|
345
|
+
unknown: string;
|
|
342
346
|
css: (d: string) => string | undefined;
|
|
343
347
|
};
|
|
344
348
|
export type GenericMarkOptions = Record<string, any>;
|