svelteplot 0.3.11-pr-153.7 → 0.3.11-pr-153.8
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/transforms/stack.js +11 -1
- package/package.json +1 -1
package/dist/transforms/stack.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import isDataRecord from '../helpers/isDataRecord.js';
|
|
2
2
|
import { resolveChannel, resolveProp } from '../helpers/resolve.js';
|
|
3
3
|
import { stack, stackOffsetExpand, stackOffsetSilhouette, stackOffsetWiggle, stackOrderAppearance, stackOrderAscending, stackOrderInsideOut, stackOrderNone, stackOffsetDiverging } from 'd3-shape';
|
|
4
|
-
import { index, union, sum, groups as d3Groups } from 'd3-array';
|
|
4
|
+
import { index, union, sum, groups as d3Groups, extent, min } from 'd3-array';
|
|
5
5
|
import { groupFacetsAndZ } from '../helpers/group';
|
|
6
6
|
import { filter } from './filter.js';
|
|
7
7
|
import { sort } from './sort.js';
|
|
@@ -118,6 +118,16 @@ const Y = Symbol('y'), Y1 = Symbol('y1'), Y2 = Symbol('y2');
|
|
|
118
118
|
export function stackMarimekko(args, { x: xOpt, y: yOpt } = {}) {
|
|
119
119
|
const out = [];
|
|
120
120
|
const { data, x, y, value, ...rest } = sort(filter(args));
|
|
121
|
+
if (data == null)
|
|
122
|
+
throw new Error('stackMarimekko: missing data');
|
|
123
|
+
if (x == null)
|
|
124
|
+
throw new Error('stackMarimekko: missing x channel');
|
|
125
|
+
if (y == null)
|
|
126
|
+
throw new Error('stackMarimekko: missing y channel');
|
|
127
|
+
if (value == null)
|
|
128
|
+
throw new Error('stackMarimekko: missing value channel');
|
|
129
|
+
if (min(data, (d) => resolveProp(d[value], d)) < 0)
|
|
130
|
+
throw new Error('stackMarimekko: negative values not supported');
|
|
121
131
|
groupFacetsAndZ(data, { ...rest }, (data) => {
|
|
122
132
|
const total = sum(data, (d) => d[value]);
|
|
123
133
|
let xPos = 0;
|