svelteplot 0.5.1-pr-238.0 → 0.5.1-pr-238.2
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/constants.d.ts +2 -1
- package/dist/constants.js +22 -0
- package/dist/helpers/reduce.js +3 -2
- package/dist/helpers/scales.js +4 -4
- package/dist/transforms/bin.js +10 -9
- package/dist/transforms/stack.js +3 -3
- package/dist/types/channel.d.ts +1 -1
- package/package.json +1 -1
package/dist/constants.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { ScaleName, ScaleType, ScaledChannelName } from './types/index.js';
|
|
1
|
+
import type { ChannelName, ScaleName, ScaleType, ScaledChannelName } from './types/index.js';
|
|
2
2
|
export declare const SCALE_TYPES: Record<ScaleName, symbol>;
|
|
3
|
+
export declare const ORIGINAL_NAME_KEYS: Record<ChannelName, symbol>;
|
|
3
4
|
export declare const SCALES: ScaleName[];
|
|
4
5
|
export declare const VALID_SCALE_TYPES: Record<ScaleName, Set<ScaleType>>;
|
|
5
6
|
/**
|
package/dist/constants.js
CHANGED
|
@@ -10,6 +10,28 @@ export const SCALE_TYPES = {
|
|
|
10
10
|
fy: Symbol('fy'),
|
|
11
11
|
projection: Symbol('projection')
|
|
12
12
|
};
|
|
13
|
+
export const ORIGINAL_NAME_KEYS = {
|
|
14
|
+
x: Symbol('origName_x'),
|
|
15
|
+
x1: Symbol('origName_x1'),
|
|
16
|
+
x2: Symbol('origName_x2'),
|
|
17
|
+
y: Symbol('origName_y'),
|
|
18
|
+
y1: Symbol('origName_y1'),
|
|
19
|
+
y2: Symbol('origName_y2'),
|
|
20
|
+
fill: Symbol('origName_color'),
|
|
21
|
+
stroke: Symbol('origName_color'),
|
|
22
|
+
opacity: Symbol('origName_opacity'),
|
|
23
|
+
symbol: Symbol('origName_symbol'),
|
|
24
|
+
r: Symbol('origName_r'),
|
|
25
|
+
z: Symbol('origName_z'),
|
|
26
|
+
sort: Symbol('origName_sort'),
|
|
27
|
+
filter: Symbol('origName_filter'),
|
|
28
|
+
interval: Symbol('origName_interval'),
|
|
29
|
+
length: Symbol('origName_length'),
|
|
30
|
+
fx: Symbol('origName_fx'),
|
|
31
|
+
fy: Symbol('origName_fy'),
|
|
32
|
+
fillOpacity: Symbol('origName_opacity'),
|
|
33
|
+
strokeOpacity: Symbol('origName_opacity')
|
|
34
|
+
};
|
|
13
35
|
export const SCALES = [
|
|
14
36
|
'x',
|
|
15
37
|
'y',
|
package/dist/helpers/reduce.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
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
|
+
import { ORIGINAL_NAME_KEYS } from '../constants.js';
|
|
4
5
|
const niceReduceNames = {
|
|
5
6
|
count: 'Frequency',
|
|
6
7
|
deviation: 'Standard Deviation',
|
|
@@ -72,10 +73,10 @@ export function reduceOutputs(newDatum, data, options, outputs, channels, newCha
|
|
|
72
73
|
if (typeof channels[k] === 'string') {
|
|
73
74
|
// the named reducer is applied to a column name, so we can use a combination
|
|
74
75
|
// of both as axis labels, e.g. MEAN(weight)
|
|
75
|
-
newChannels[
|
|
76
|
+
newChannels[ORIGINAL_NAME_KEYS[k]] = `${reducerName} ( ${channels[k]} )`;
|
|
76
77
|
}
|
|
77
78
|
else {
|
|
78
|
-
newChannels[
|
|
79
|
+
newChannels[ORIGINAL_NAME_KEYS[k]] = reducerName;
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
82
|
}
|
package/dist/helpers/scales.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { extent, ascending } from 'd3-array';
|
|
2
2
|
import { isColorOrNull, isDate, isDateOrNull, isNumberOrNull, isNumberOrNullOrNaN, isStringOrNull } from './typeChecks.js';
|
|
3
|
-
import { CHANNEL_SCALE, VALID_SCALE_TYPES } from '../constants.js';
|
|
3
|
+
import { CHANNEL_SCALE, ORIGINAL_NAME_KEYS, VALID_SCALE_TYPES } from '../constants.js';
|
|
4
4
|
import { isSymbolOrNull } from './typeChecks.js';
|
|
5
5
|
import { resolveProp, toChannelOption } from './resolve.js';
|
|
6
6
|
import isDataRecord from './isDataRecord.js';
|
|
@@ -126,9 +126,9 @@ export function createScale(name, scaleOptions, marks, plotOptions, plotWidth, p
|
|
|
126
126
|
}
|
|
127
127
|
// special handling of marks using the stackX/stackY transform
|
|
128
128
|
if ((name === 'x' || name === 'y') &&
|
|
129
|
-
mark.options[
|
|
130
|
-
!mark.options[
|
|
131
|
-
propNames.add(mark.options[
|
|
129
|
+
mark.options[ORIGINAL_NAME_KEYS[name]] &&
|
|
130
|
+
!mark.options[ORIGINAL_NAME_KEYS[name]].startsWith('__')) {
|
|
131
|
+
propNames.add(mark.options[ORIGINAL_NAME_KEYS[name]]);
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
else {
|
package/dist/transforms/bin.js
CHANGED
|
@@ -4,6 +4,7 @@ import { bin as d3Bin, extent, thresholdFreedmanDiaconis, thresholdScott, thresh
|
|
|
4
4
|
import { reduceOutputs } from '../helpers/reduce.js';
|
|
5
5
|
import { groupFacetsAndZ } from '../helpers/group.js';
|
|
6
6
|
import { isDate } from '../helpers/typeChecks.js';
|
|
7
|
+
import { ORIGINAL_NAME_KEYS } from '../constants';
|
|
7
8
|
const CHANNELS = {
|
|
8
9
|
x: Symbol('x'),
|
|
9
10
|
x1: Symbol('x1'),
|
|
@@ -49,19 +50,19 @@ function binBy(byDim, { data, ...channels }, options) {
|
|
|
49
50
|
[byDim === 'x' ? 'insetLeft' : 'insetTop']: 0.5,
|
|
50
51
|
[byDim === 'x' ? 'insetRight' : 'insetBottom']: 0.5,
|
|
51
52
|
...channels,
|
|
52
|
-
[`${byDim}`]: `__${byDim}`,
|
|
53
|
-
[`${byDim}1`]:
|
|
54
|
-
[`${byDim}2`]:
|
|
55
|
-
[
|
|
53
|
+
[`${byDim}`]: CHANNELS[byDim], // `__${byDim}`,
|
|
54
|
+
[`${byDim}1`]: CHANNELS[`${byDim}1`],
|
|
55
|
+
[`${byDim}2`]: CHANNELS[`${byDim}2`],
|
|
56
|
+
[ORIGINAL_NAME_KEYS[byDim]]: typeof channels[byDim] === 'string' ? channels[byDim] : null
|
|
56
57
|
};
|
|
57
58
|
const newData = [];
|
|
58
59
|
let passedGroups = [];
|
|
59
60
|
const bins = bin(data);
|
|
60
61
|
(options.cumulative < 0 ? bins.toReversed() : bins).forEach((group) => {
|
|
61
62
|
const itemBinProps = {
|
|
62
|
-
[
|
|
63
|
-
[
|
|
64
|
-
[
|
|
63
|
+
[CHANNELS[`${byDim}1`]]: group.x0,
|
|
64
|
+
[CHANNELS[`${byDim}2`]]: group.x1,
|
|
65
|
+
[CHANNELS[`${byDim}`]]: isDate(group.x0)
|
|
65
66
|
? new Date(Math.round((group.x0.getTime() + group.x1.getTime()) * 0.5))
|
|
66
67
|
: (group.x0 + group.x1) * 0.5
|
|
67
68
|
};
|
|
@@ -139,8 +140,8 @@ export function bin({ data, ...channels }, options = { thresholds: 'auto', cumul
|
|
|
139
140
|
y: CHANNELS.y,
|
|
140
141
|
y1: CHANNELS.y1,
|
|
141
142
|
y2: CHANNELS.y2,
|
|
142
|
-
|
|
143
|
-
|
|
143
|
+
[ORIGINAL_NAME_KEYS.x]: typeof channels.x === 'string' ? channels.x : null,
|
|
144
|
+
[ORIGINAL_NAME_KEYS.y]: typeof channels.y === 'string' ? channels.y : null
|
|
144
145
|
};
|
|
145
146
|
const groupBy = channels.z ? 'z' : channels.fill ? 'fill' : channels.stroke ? 'stroke' : true;
|
|
146
147
|
const groupByPropName = groupBy !== true && typeof channels[groupBy] === 'string' ? channels[groupBy] : '__group';
|
package/dist/transforms/stack.js
CHANGED
|
@@ -5,7 +5,7 @@ import { sum, groups as d3Groups, min, range } from 'd3-array';
|
|
|
5
5
|
import { groupFacetsAndZ } from '../helpers/group';
|
|
6
6
|
import { filter } from './filter.js';
|
|
7
7
|
import { sort } from './sort.js';
|
|
8
|
-
import { INDEX } from '../constants.js';
|
|
8
|
+
import { INDEX, ORIGINAL_NAME_KEYS } from '../constants.js';
|
|
9
9
|
import { indexData, RAW_VALUE } from './recordize.js';
|
|
10
10
|
const S = {
|
|
11
11
|
x: Symbol('x'),
|
|
@@ -143,8 +143,8 @@ function stackXY(byDim, data, channels, options) {
|
|
|
143
143
|
data: out,
|
|
144
144
|
...channels,
|
|
145
145
|
[byDim]: undefined,
|
|
146
|
-
...(typeof channels[byDim] === 'string' && !channels[
|
|
147
|
-
? { [
|
|
146
|
+
...(typeof channels[byDim] === 'string' && !channels[ORIGINAL_NAME_KEYS[byDim]]
|
|
147
|
+
? { [ORIGINAL_NAME_KEYS[byDim]]: channels[byDim] }
|
|
148
148
|
: {}),
|
|
149
149
|
...{ [byLow]: S[byLow], [byHigh]: S[byHigh] }
|
|
150
150
|
};
|
package/dist/types/channel.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ConstantAccessor, RawValue } from './index.js';
|
|
2
|
-
export type Channels<T> = Record<string, ChannelAccessor<T> | ConstantAccessor<T, string | number | boolean | symbol>>;
|
|
2
|
+
export type Channels<T> = Record<string | symbol, ChannelAccessor<T> | ConstantAccessor<T, string | number | boolean | symbol>>;
|
|
3
3
|
export type ChannelAccessor<T = Record<string | symbol, RawValue>> = ChannelValue<T> | {
|
|
4
4
|
/** the channel value */
|
|
5
5
|
value: ChannelValue<T>;
|