svelteplot 0.10.3-pr-477.2 → 0.10.3-pr-477.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.
@@ -1,5 +1,5 @@
1
1
  import type { ColorScaleOptions, PlotDefaults, PlotOptions, RawValue, ScaleName, ScaleOptions, ScaleType } from '../types/index.js';
2
- export declare function autoScale({ name, type, domain, scaleOptions, plotOptions, plotWidth, plotHeight, plotHasFilledDotMarks, plotDefaults }: {
2
+ export declare function autoScale({ name, type, domain, scaleOptions, plotOptions, plotWidth, plotHeight, plotHasFilledDotMarks, plotDefaults: _plotDefaults }: {
3
3
  name: ScaleName;
4
4
  type: ScaleType;
5
5
  domain: RawValue[];
@@ -10,7 +10,7 @@ export declare function autoScale({ name, type, domain, scaleOptions, plotOption
10
10
  plotHasFilledDotMarks: boolean;
11
11
  plotDefaults: PlotDefaults;
12
12
  }): any;
13
- export declare function autoScaleColor({ type, domain, scaleOptions, plotOptions, plotWidth, plotHeight, plotHasFilledDotMarks, plotDefaults }: {
13
+ export declare function autoScaleColor({ type, domain, scaleOptions, plotOptions: _plotOptions, plotWidth: _plotWidth, plotHeight: _plotHeight, plotHasFilledDotMarks: _plotHasFilledDotMarks, plotDefaults }: {
14
14
  name: ScaleName;
15
15
  type: ScaleType;
16
16
  domain: RawValue[];
@@ -41,7 +41,7 @@ const ThresholdScales = {
41
41
  quantize: scaleQuantize,
42
42
  quantile: scaleQuantile
43
43
  };
44
- export function autoScale({ name, type, domain, scaleOptions, plotOptions, plotWidth, plotHeight, plotHasFilledDotMarks, plotDefaults }) {
44
+ export function autoScale({ name, type, domain, scaleOptions, plotOptions, plotWidth, plotHeight, plotHasFilledDotMarks, plotDefaults: _plotDefaults }) {
45
45
  let fn;
46
46
  let range;
47
47
  range =
@@ -110,7 +110,7 @@ export function autoScale({ name, type, domain, scaleOptions, plotOptions, plotW
110
110
  }
111
111
  return fn;
112
112
  }
113
- export function autoScaleColor({ type, domain, scaleOptions, plotOptions, plotWidth, plotHeight, plotHasFilledDotMarks, plotDefaults }) {
113
+ export function autoScaleColor({ type, domain, scaleOptions, plotOptions: _plotOptions, plotWidth: _plotWidth, plotHeight: _plotHeight, plotHasFilledDotMarks: _plotHasFilledDotMarks, plotDefaults }) {
114
114
  let fn;
115
115
  let range;
116
116
  // special treatment for color scales
@@ -93,7 +93,6 @@ const scaledStyleProps = {
93
93
  strokeOpacity: 'stroke-opacity',
94
94
  opacity: 'opacity'
95
95
  };
96
- const scaledStylePropsKeys = Object.keys(scaledStyleProps);
97
96
  // TODO: find a better name
98
97
  const oppositeColor = {
99
98
  fill: 'stroke',
@@ -103,7 +103,7 @@ export function binY({ data, ...channels }, options = { thresholds: 'auto', cumu
103
103
  * for binning in x and y dimension simultaneously
104
104
  */
105
105
  export function bin({ data, ...channels }, options = { thresholds: 'auto', cumulative: false }) {
106
- const { domain, thresholds = 'auto', interval, cumulative = false } = options;
106
+ const { domain, thresholds = 'auto', interval } = options;
107
107
  const binX = d3Bin();
108
108
  const binY = d3Bin();
109
109
  if (domain) {
@@ -169,7 +169,7 @@ export function bin({ data, ...channels }, options = { thresholds: 'auto', cumul
169
169
  const [ylo, yhi] = extent(groupX.map((d) => resolveChannel('y', d, channels)));
170
170
  const tExtentLo = yThresholds.filter((d) => d < ylo).at(-1) ?? ylo;
171
171
  const tExtentHi = yThresholds.filter((d) => d > yhi).at(0) ?? yhi;
172
- binY(groupX).forEach((groupY, i) => {
172
+ binY(groupX).forEach((groupY) => {
173
173
  if (groupY.length === 0)
174
174
  return;
175
175
  // The first bin.x0 is always equal to the minimum domain value,
@@ -46,7 +46,7 @@ function bollinger(values, N, K) {
46
46
  const value = values[i];
47
47
  ((sum += value), (sumSquared += value ** 2));
48
48
  }
49
- for (let n = values.length, m = bands.length; i < n; ++i) {
49
+ for (let n = values.length; i < n; ++i) {
50
50
  const value = values[i];
51
51
  ((sum += value), (sumSquared += value ** 2));
52
52
  const mean = sum / N;
@@ -4,7 +4,7 @@
4
4
  import type { TransformArg } from '../types';
5
5
  export type KernelName = 'uniform' | 'triangular' | 'epanechnikov' | 'quartic' | 'triweight' | 'gaussian' | 'cosine';
6
6
  export type Kernel = KernelName | ((u: number) => number);
7
- export type DensityOptions<T> = {
7
+ export type DensityOptions<_T> = {
8
8
  /**
9
9
  * The kernel function to use for smoothing.
10
10
  */
@@ -156,9 +156,9 @@ function density1d(independent, { data, weight, ...channels }, options = {}) {
156
156
  .sort((a, b) => a[0] - b[0]);
157
157
  if (!trim) {
158
158
  // trim zero values at begin and end except first and last
159
- const firstNonZero = kdeValues.findIndex(([x, v]) => v > 0);
159
+ const firstNonZero = kdeValues.findIndex(([_x, v]) => v > 0);
160
160
  // if (firstNonZero > 0) minX = Math.min(minX, kdeValues[firstNonZero - 1][0]);
161
- const lastNonZero = kdeValues.length - 1 - [...kdeValues].reverse().findIndex(([x, v]) => v > 0);
161
+ const lastNonZero = kdeValues.length - 1 - [...kdeValues].reverse().findIndex(([_x, v]) => v > 0);
162
162
  // if (lastNonZero > -1 && lastNonZero < kdeValues.length - 1)
163
163
  // maxX = Math.max(maxX, kdeValues[lastNonZero + 1][0]);
164
164
  kdeValues = kdeValues.slice(firstNonZero < 1 ? 0 : firstNonZero - 1, lastNonZero < 0 ? kdeValues.length : lastNonZero + 1);
@@ -126,7 +126,7 @@ function anchorYTop({ options: { marginTop } }) {
126
126
  function anchorYBottom({ facetHeight: height }) {
127
127
  return [-1, height];
128
128
  }
129
- function anchorYMiddle({ facetHeight: height, options: { marginTop, marginBottom } }) {
129
+ function anchorYMiddle({ facetHeight: height, options: { marginTop, marginBottom: _marginBottom } }) {
130
130
  return [0, (marginTop + height) / 2];
131
131
  }
132
132
  function compareSymmetric(a, b) {
@@ -77,7 +77,7 @@ function parseNumber(value) {
77
77
  const [name, period] = parseTimeInterval(value);
78
78
  return (durations.get(name) ?? 0) * period;
79
79
  }
80
- catch (err) {
80
+ catch {
81
81
  return 0;
82
82
  }
83
83
  }
@@ -15,7 +15,7 @@ export function recordizeX({ data, ...channels }, { withIndex } = { withIndex: t
15
15
  if (dataIsRawValueArray) {
16
16
  // we remove x, x1 and x2 from the channels since they make no sense when
17
17
  // the data is a raw value array
18
- const { x, x1, x2, ...nonXChannels } = channels;
18
+ const { x: _x, x1: _x1, x2: _x2, ...nonXChannels } = channels;
19
19
  return {
20
20
  data: data.map((value, index) => ({
21
21
  [RAW_VALUE]: value,
@@ -39,7 +39,7 @@ export function recordizeY({ data, ...channels }, { withIndex } = { withIndex: t
39
39
  if (dataIsRawValueArray) {
40
40
  // we remove y, y1 and y2 from the channels since they make no sense when
41
41
  // the data is a raw value array
42
- const { y, y1, y2, ...nonYChannels } = channels;
42
+ const { y: _y, y1: _y1, y2: _y2, ...nonYChannels } = channels;
43
43
  return {
44
44
  data: Array.from(data).map((value, index) => ({
45
45
  [INDEX]: index,
@@ -55,7 +55,7 @@ function stackXY(byDim, data, channels, options) {
55
55
  channels[`${byLow}`] === undefined &&
56
56
  channels[`${byHigh}`] === undefined) {
57
57
  // resolve all channels for easier computation below
58
- const resolvedData = indexData(data).map((d, i) => ({
58
+ const resolvedData = indexData(data).map((d) => ({
59
59
  ...(isDataRecord(d) ? d : { [RAW_VALUE]: d }),
60
60
  [S[secondDim]]: resolveChannel(secondDim, d, channels),
61
61
  [GROUP]: groupBy === true ? 'G' : resolveChannel(groupBy, d, channels),
@@ -91,7 +91,7 @@ function stackXY(byDim, data, channels, options) {
91
91
  // Unit stacking: map each secondary-dimension bucket to an array of values.
92
92
  // Series are positional (0..N-1) within each bucket.
93
93
  let maxKeys = 0;
94
- stackData = groupedBySecondDim.map(([k, items]) => {
94
+ stackData = groupedBySecondDim.map(([_k, items]) => {
95
95
  const values = items
96
96
  // keep original order within bucket; no stable series identity across buckets
97
97
  .map((d) => ({ i: d[INDEX], v: d[S[byDim]] }));
@@ -104,7 +104,7 @@ function stackXY(byDim, data, channels, options) {
104
104
  else {
105
105
  // Grouped stacking: keep consistent series identities using the group key
106
106
  const keySet = new Set(facetData.map((d) => d[GROUP]));
107
- stackData = groupedBySecondDim.map(([k, items]) => {
107
+ stackData = groupedBySecondDim.map(([_k, items]) => {
108
108
  const obj = {};
109
109
  items.forEach((d) => {
110
110
  const key = d[GROUP];
@@ -134,7 +134,7 @@ function stackXY(byDim, data, channels, options) {
134
134
  ? STACK_OFFSET['center']
135
135
  : STACK_OFFSET[options.offset ?? 'none']))
136
136
  .keys(keys)
137
- .value((d, key, i, data) => {
137
+ .value((d, key, _i, _data) => {
138
138
  return d[key]?.v == null ? undefined : d[key]?.v;
139
139
  })(stackData);
140
140
  // and combine it all back into a flat array
@@ -205,7 +205,7 @@ function stackMosaic({ data, x, y, value, fx, fy, ...rest }, { outer, inner }, {
205
205
  const innerOpt = inner === 'x' ? xOpt : yOpt;
206
206
  const grouped = d3Groups(data, (d) => resolveProp(d[outerChannel], d));
207
207
  const innerOrder = new Map(grouped[0][1].map((d, i) => [d[innerChannel], i]));
208
- grouped.forEach(([k, items], i) => {
208
+ grouped.forEach(([_k, items], i) => {
209
209
  const groupValue = sum(items, (d) => resolveProp(d[value], d));
210
210
  const o1 = outerPos, o2 = outerPos + groupValue;
211
211
  outerPos = o2;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelteplot",
3
- "version": "0.10.3-pr-477.2",
3
+ "version": "0.10.3-pr-477.3",
4
4
  "description": "A Svelte-native data visualization framework based on the layered grammar of graphics principles.",
5
5
  "keywords": [
6
6
  "svelte",