victory-stack 36.8.2 → 36.8.4
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/CHANGELOG.md +8 -0
- package/dist/victory-stack.js +164 -163
- package/dist/victory-stack.min.js +1 -1
- package/es/helper-methods.d.ts +2 -2
- package/es/helper-methods.js +26 -28
- package/es/victory-stack.d.ts +1 -0
- package/lib/helper-methods.d.ts +2 -2
- package/lib/helper-methods.js +30 -28
- package/lib/victory-stack.d.ts +1 -0
- package/package.json +3 -3
- package/src/helper-methods.tsx +32 -24
package/es/helper-methods.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function getCalculatedProps(
|
|
1
|
+
export declare function getCalculatedProps(initialProps: any, childComponents: any): {
|
|
2
2
|
datasets: any;
|
|
3
3
|
categories: any;
|
|
4
4
|
range: any;
|
|
@@ -49,5 +49,5 @@ export declare function getChildProps(props: any, calculatedProps: any): {
|
|
|
49
49
|
scale: any;
|
|
50
50
|
horizontal: any;
|
|
51
51
|
};
|
|
52
|
-
export declare function getChildren(
|
|
52
|
+
export declare function getChildren(initialProps: any, childComponents: any, calculatedProps: any): any;
|
|
53
53
|
//# sourceMappingURL=helper-methods.d.ts.map
|
package/es/helper-methods.js
CHANGED
|
@@ -48,13 +48,13 @@ function fillData(props, datasets) {
|
|
|
48
48
|
var indexOffset = 0;
|
|
49
49
|
var isDate = dataset[0] && dataset[0]._x instanceof Date;
|
|
50
50
|
var filledInData = xArr.map(function (x, index) {
|
|
51
|
-
|
|
51
|
+
var parsedX = Number(x);
|
|
52
52
|
var datum = dataset[index - indexOffset];
|
|
53
53
|
|
|
54
54
|
if (datum) {
|
|
55
55
|
var x1 = isDate ? datum._x.getTime() : datum._x;
|
|
56
56
|
|
|
57
|
-
if (x1 ===
|
|
57
|
+
if (x1 === parsedX) {
|
|
58
58
|
return datum;
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -62,21 +62,21 @@ function fillData(props, datasets) {
|
|
|
62
62
|
|
|
63
63
|
var _y = fillInMissingData ? 0 : null;
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
parsedX = isDate ? new Date(parsedX) : parsedX;
|
|
66
66
|
return {
|
|
67
|
-
x:
|
|
67
|
+
x: parsedX,
|
|
68
68
|
y: _y,
|
|
69
|
-
_x:
|
|
69
|
+
_x: parsedX,
|
|
70
70
|
_y: _y
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
var y = fillInMissingData ? 0 : null;
|
|
75
|
-
|
|
75
|
+
parsedX = isDate ? new Date(parsedX) : parsedX;
|
|
76
76
|
return {
|
|
77
|
-
x:
|
|
77
|
+
x: parsedX,
|
|
78
78
|
y: y,
|
|
79
|
-
_x:
|
|
79
|
+
_x: parsedX,
|
|
80
80
|
_y: y
|
|
81
81
|
};
|
|
82
82
|
});
|
|
@@ -140,14 +140,14 @@ function stackData(props, childComponents) {
|
|
|
140
140
|
});
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
export function getCalculatedProps(
|
|
144
|
-
|
|
143
|
+
export function getCalculatedProps(initialProps, childComponents) {
|
|
144
|
+
var children = childComponents || React.Children.toArray(initialProps.children);
|
|
145
145
|
var role = "stack";
|
|
146
|
-
props = Helpers.modifyProps(
|
|
146
|
+
var props = Helpers.modifyProps(initialProps, fallbackProps, role);
|
|
147
147
|
var style = Wrapper.getStyle(props.theme, props.style, role);
|
|
148
|
-
var categories = props.categories || Wrapper.getCategories(props,
|
|
149
|
-
var datasets = props.datasets || stackData(props,
|
|
150
|
-
var
|
|
148
|
+
var categories = props.categories || Wrapper.getCategories(props, children);
|
|
149
|
+
var datasets = props.datasets || stackData(props, children);
|
|
150
|
+
var clonedChildren = children.map(function (c, i) {
|
|
151
151
|
return /*#__PURE__*/React.cloneElement(c, {
|
|
152
152
|
data: datasets[i]
|
|
153
153
|
});
|
|
@@ -155,10 +155,10 @@ export function getCalculatedProps(props, childComponents) {
|
|
|
155
155
|
var domain = {
|
|
156
156
|
x: Wrapper.getDomain(_assign({}, props, {
|
|
157
157
|
categories: categories
|
|
158
|
-
}), "x",
|
|
158
|
+
}), "x", clonedChildren),
|
|
159
159
|
y: Wrapper.getDomain(_assign({}, props, {
|
|
160
160
|
categories: categories
|
|
161
|
-
}), "y",
|
|
161
|
+
}), "y", clonedChildren)
|
|
162
162
|
};
|
|
163
163
|
var range = props.range || {
|
|
164
164
|
x: Helpers.getRange(props, "x"),
|
|
@@ -172,9 +172,8 @@ export function getCalculatedProps(props, childComponents) {
|
|
|
172
172
|
x: baseScale.x.domain(domain.x).range(props.horizontal ? range.y : range.x),
|
|
173
173
|
y: baseScale.y.domain(domain.y).range(props.horizontal ? range.x : range.y)
|
|
174
174
|
};
|
|
175
|
-
var
|
|
176
|
-
|
|
177
|
-
horizontal = _props.horizontal;
|
|
175
|
+
var colorScale = props.colorScale,
|
|
176
|
+
horizontal = props.horizontal;
|
|
178
177
|
return {
|
|
179
178
|
datasets: datasets,
|
|
180
179
|
categories: categories,
|
|
@@ -260,18 +259,17 @@ function getColorScale(props, child) {
|
|
|
260
259
|
return props.theme ? colorScaleOptions || props.theme.props.colorScale : colorScaleOptions;
|
|
261
260
|
}
|
|
262
261
|
|
|
263
|
-
export function getChildren(
|
|
264
|
-
props = Helpers.modifyProps(
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
var
|
|
268
|
-
|
|
269
|
-
var childProps = getChildProps(props, calculatedProps);
|
|
262
|
+
export function getChildren(initialProps, childComponents, calculatedProps) {
|
|
263
|
+
var props = Helpers.modifyProps(initialProps, fallbackProps, "stack");
|
|
264
|
+
var children = childComponents || React.Children.toArray(props.children);
|
|
265
|
+
var newCalculatedProps = calculatedProps || getCalculatedProps(props, children);
|
|
266
|
+
var datasets = newCalculatedProps.datasets;
|
|
267
|
+
var childProps = getChildProps(props, newCalculatedProps);
|
|
270
268
|
var parentName = props.name || "stack";
|
|
271
|
-
return
|
|
269
|
+
return children.map(function (child, index) {
|
|
272
270
|
var role = child.type && child.type.role;
|
|
273
271
|
var data = datasets[index];
|
|
274
|
-
var style = Wrapper.getChildStyle(child, index,
|
|
272
|
+
var style = Wrapper.getChildStyle(child, index, newCalculatedProps);
|
|
275
273
|
var labels = props.labels ? getLabels(props, datasets, index) : child.props.labels;
|
|
276
274
|
var name = child.props.name || "".concat(parentName, "-").concat(role, "-").concat(index);
|
|
277
275
|
return /*#__PURE__*/React.cloneElement(child, _assign({
|
package/es/victory-stack.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ export declare const VictoryStack: React.NamedExoticComponent<VictoryStackProps>
|
|
|
38
38
|
theme?: React.Validator<import("victory-core").VictoryThemeDefinition | null | undefined> | undefined;
|
|
39
39
|
animate?: React.Validator<boolean | import("victory-core").AnimatePropTypeInterface | null | undefined> | undefined;
|
|
40
40
|
containerComponent?: React.Validator<React.ReactElement<any, string | React.JSXElementConstructor<any>> | null | undefined> | undefined;
|
|
41
|
+
disableInlineStyles?: React.Validator<boolean | null | undefined> | undefined;
|
|
41
42
|
domainPadding?: React.Validator<import("victory-core").ForAxes<import("victory-core").PaddingType> | null | undefined> | undefined;
|
|
42
43
|
externalEventMutations?: React.Validator<import("victory-core").EventCallbackInterface<string | string[], import("victory-core").StringOrNumberOrList>[] | null | undefined> | undefined;
|
|
43
44
|
groupComponent?: React.Validator<React.ReactElement<any, string | React.JSXElementConstructor<any>> | null | undefined> | undefined;
|
package/lib/helper-methods.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function getCalculatedProps(
|
|
1
|
+
export declare function getCalculatedProps(initialProps: any, childComponents: any): {
|
|
2
2
|
datasets: any;
|
|
3
3
|
categories: any;
|
|
4
4
|
range: any;
|
|
@@ -49,5 +49,5 @@ export declare function getChildProps(props: any, calculatedProps: any): {
|
|
|
49
49
|
scale: any;
|
|
50
50
|
horizontal: any;
|
|
51
51
|
};
|
|
52
|
-
export declare function getChildren(
|
|
52
|
+
export declare function getChildren(initialProps: any, childComponents: any, calculatedProps: any): any;
|
|
53
53
|
//# sourceMappingURL=helper-methods.d.ts.map
|
package/lib/helper-methods.js
CHANGED
|
@@ -62,13 +62,13 @@ function fillData(props, datasets) {
|
|
|
62
62
|
var indexOffset = 0;
|
|
63
63
|
var isDate = dataset[0] && dataset[0]._x instanceof Date;
|
|
64
64
|
var filledInData = xArr.map(function (x, index) {
|
|
65
|
-
|
|
65
|
+
var parsedX = Number(x);
|
|
66
66
|
var datum = dataset[index - indexOffset];
|
|
67
67
|
|
|
68
68
|
if (datum) {
|
|
69
69
|
var x1 = isDate ? datum._x.getTime() : datum._x;
|
|
70
70
|
|
|
71
|
-
if (x1 ===
|
|
71
|
+
if (x1 === parsedX) {
|
|
72
72
|
return datum;
|
|
73
73
|
}
|
|
74
74
|
|
|
@@ -76,21 +76,21 @@ function fillData(props, datasets) {
|
|
|
76
76
|
|
|
77
77
|
var _y = fillInMissingData ? 0 : null;
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
parsedX = isDate ? new Date(parsedX) : parsedX;
|
|
80
80
|
return {
|
|
81
|
-
x:
|
|
81
|
+
x: parsedX,
|
|
82
82
|
y: _y,
|
|
83
|
-
_x:
|
|
83
|
+
_x: parsedX,
|
|
84
84
|
_y: _y
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
var y = fillInMissingData ? 0 : null;
|
|
89
|
-
|
|
89
|
+
parsedX = isDate ? new Date(parsedX) : parsedX;
|
|
90
90
|
return {
|
|
91
|
-
x:
|
|
91
|
+
x: parsedX,
|
|
92
92
|
y: y,
|
|
93
|
-
_x:
|
|
93
|
+
_x: parsedX,
|
|
94
94
|
_y: y
|
|
95
95
|
};
|
|
96
96
|
});
|
|
@@ -155,17 +155,19 @@ function stackData(props, childComponents) {
|
|
|
155
155
|
});
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
function getCalculatedProps(
|
|
159
|
-
|
|
158
|
+
function getCalculatedProps(initialProps, childComponents) {
|
|
159
|
+
var children = childComponents || _react.default.Children.toArray(initialProps.children);
|
|
160
|
+
|
|
160
161
|
var role = "stack";
|
|
161
|
-
|
|
162
|
+
|
|
163
|
+
var props = _victoryCore.Helpers.modifyProps(initialProps, fallbackProps, role);
|
|
162
164
|
|
|
163
165
|
var style = _victoryCore.Wrapper.getStyle(props.theme, props.style, role);
|
|
164
166
|
|
|
165
|
-
var categories = props.categories || _victoryCore.Wrapper.getCategories(props,
|
|
167
|
+
var categories = props.categories || _victoryCore.Wrapper.getCategories(props, children);
|
|
166
168
|
|
|
167
|
-
var datasets = props.datasets || stackData(props,
|
|
168
|
-
var
|
|
169
|
+
var datasets = props.datasets || stackData(props, children);
|
|
170
|
+
var clonedChildren = children.map(function (c, i) {
|
|
169
171
|
return /*#__PURE__*/_react.default.cloneElement(c, {
|
|
170
172
|
data: datasets[i]
|
|
171
173
|
});
|
|
@@ -173,10 +175,10 @@ function getCalculatedProps(props, childComponents) {
|
|
|
173
175
|
var domain = {
|
|
174
176
|
x: _victoryCore.Wrapper.getDomain((0, _assign2.default)({}, props, {
|
|
175
177
|
categories: categories
|
|
176
|
-
}), "x",
|
|
178
|
+
}), "x", clonedChildren),
|
|
177
179
|
y: _victoryCore.Wrapper.getDomain((0, _assign2.default)({}, props, {
|
|
178
180
|
categories: categories
|
|
179
|
-
}), "y",
|
|
181
|
+
}), "y", clonedChildren)
|
|
180
182
|
};
|
|
181
183
|
var range = props.range || {
|
|
182
184
|
x: _victoryCore.Helpers.getRange(props, "x"),
|
|
@@ -190,9 +192,8 @@ function getCalculatedProps(props, childComponents) {
|
|
|
190
192
|
x: baseScale.x.domain(domain.x).range(props.horizontal ? range.y : range.x),
|
|
191
193
|
y: baseScale.y.domain(domain.y).range(props.horizontal ? range.x : range.y)
|
|
192
194
|
};
|
|
193
|
-
var
|
|
194
|
-
|
|
195
|
-
horizontal = _props.horizontal;
|
|
195
|
+
var colorScale = props.colorScale,
|
|
196
|
+
horizontal = props.horizontal;
|
|
196
197
|
return {
|
|
197
198
|
datasets: datasets,
|
|
198
199
|
categories: categories,
|
|
@@ -282,19 +283,20 @@ function getColorScale(props, child) {
|
|
|
282
283
|
return props.theme ? colorScaleOptions || props.theme.props.colorScale : colorScaleOptions;
|
|
283
284
|
}
|
|
284
285
|
|
|
285
|
-
function getChildren(
|
|
286
|
-
props = _victoryCore.Helpers.modifyProps(
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
var
|
|
286
|
+
function getChildren(initialProps, childComponents, calculatedProps) {
|
|
287
|
+
var props = _victoryCore.Helpers.modifyProps(initialProps, fallbackProps, "stack");
|
|
288
|
+
|
|
289
|
+
var children = childComponents || _react.default.Children.toArray(props.children);
|
|
290
|
+
|
|
291
|
+
var newCalculatedProps = calculatedProps || getCalculatedProps(props, children);
|
|
292
|
+
var datasets = newCalculatedProps.datasets;
|
|
293
|
+
var childProps = getChildProps(props, newCalculatedProps);
|
|
292
294
|
var parentName = props.name || "stack";
|
|
293
|
-
return
|
|
295
|
+
return children.map(function (child, index) {
|
|
294
296
|
var role = child.type && child.type.role;
|
|
295
297
|
var data = datasets[index];
|
|
296
298
|
|
|
297
|
-
var style = _victoryCore.Wrapper.getChildStyle(child, index,
|
|
299
|
+
var style = _victoryCore.Wrapper.getChildStyle(child, index, newCalculatedProps);
|
|
298
300
|
|
|
299
301
|
var labels = props.labels ? getLabels(props, datasets, index) : child.props.labels;
|
|
300
302
|
var name = child.props.name || "".concat(parentName, "-").concat(role, "-").concat(index);
|
package/lib/victory-stack.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ export declare const VictoryStack: React.NamedExoticComponent<VictoryStackProps>
|
|
|
38
38
|
theme?: React.Validator<import("victory-core").VictoryThemeDefinition | null | undefined> | undefined;
|
|
39
39
|
animate?: React.Validator<boolean | import("victory-core").AnimatePropTypeInterface | null | undefined> | undefined;
|
|
40
40
|
containerComponent?: React.Validator<React.ReactElement<any, string | React.JSXElementConstructor<any>> | null | undefined> | undefined;
|
|
41
|
+
disableInlineStyles?: React.Validator<boolean | null | undefined> | undefined;
|
|
41
42
|
domainPadding?: React.Validator<import("victory-core").ForAxes<import("victory-core").PaddingType> | null | undefined> | undefined;
|
|
42
43
|
externalEventMutations?: React.Validator<import("victory-core").EventCallbackInterface<string | string[], import("victory-core").StringOrNumberOrList>[] | null | undefined> | undefined;
|
|
43
44
|
groupComponent?: React.Validator<React.ReactElement<any, string | React.JSXElementConstructor<any>> | null | undefined> | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "victory-stack",
|
|
3
|
-
"version": "36.8.
|
|
3
|
+
"version": "36.8.4",
|
|
4
4
|
"description": "Stack Layout Component for Victory",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"data visualization",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"lodash": "^4.17.19",
|
|
24
24
|
"prop-types": "^15.8.1",
|
|
25
25
|
"react-fast-compare": "^3.2.0",
|
|
26
|
-
"victory-core": "^36.8.
|
|
27
|
-
"victory-shared-events": "^36.8.
|
|
26
|
+
"victory-core": "^36.8.4",
|
|
27
|
+
"victory-shared-events": "^36.8.4"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"react": ">=16.6.0"
|
package/src/helper-methods.tsx
CHANGED
|
@@ -26,22 +26,22 @@ function fillData(props, datasets) {
|
|
|
26
26
|
let indexOffset = 0;
|
|
27
27
|
const isDate = dataset[0] && dataset[0]._x instanceof Date;
|
|
28
28
|
const filledInData = xArr.map((x: number | Date, index) => {
|
|
29
|
-
|
|
29
|
+
let parsedX: number | Date = Number(x);
|
|
30
30
|
const datum = dataset[index - indexOffset];
|
|
31
31
|
|
|
32
32
|
if (datum) {
|
|
33
33
|
const x1 = isDate ? datum._x.getTime() : datum._x;
|
|
34
|
-
if (x1 ===
|
|
34
|
+
if (x1 === parsedX) {
|
|
35
35
|
return datum;
|
|
36
36
|
}
|
|
37
37
|
indexOffset++;
|
|
38
38
|
const y = fillInMissingData ? 0 : null;
|
|
39
|
-
|
|
40
|
-
return { x, y, _x:
|
|
39
|
+
parsedX = isDate ? new Date(parsedX) : parsedX;
|
|
40
|
+
return { x: parsedX, y, _x: parsedX, _y: y };
|
|
41
41
|
}
|
|
42
42
|
const y = fillInMissingData ? 0 : null;
|
|
43
|
-
|
|
44
|
-
return { x, y, _x:
|
|
43
|
+
parsedX = isDate ? new Date(parsedX) : parsedX;
|
|
44
|
+
return { x: parsedX, y, _x: parsedX, _y: y };
|
|
45
45
|
});
|
|
46
46
|
|
|
47
47
|
return filledInData;
|
|
@@ -117,20 +117,28 @@ function stackData(props, childComponents) {
|
|
|
117
117
|
return datasets.map((d, i) => addLayoutData(props, datasets, i));
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
export function getCalculatedProps(
|
|
121
|
-
|
|
120
|
+
export function getCalculatedProps(initialProps, childComponents) {
|
|
121
|
+
const children =
|
|
122
|
+
childComponents || React.Children.toArray(initialProps.children);
|
|
122
123
|
const role = "stack";
|
|
123
|
-
props = Helpers.modifyProps(
|
|
124
|
+
const props = Helpers.modifyProps(initialProps, fallbackProps, role);
|
|
124
125
|
const style = Wrapper.getStyle(props.theme, props.style, role);
|
|
125
|
-
const categories =
|
|
126
|
-
|
|
127
|
-
const
|
|
128
|
-
const children = childComponents.map((c, i) => {
|
|
126
|
+
const categories = props.categories || Wrapper.getCategories(props, children);
|
|
127
|
+
const datasets = props.datasets || stackData(props, children);
|
|
128
|
+
const clonedChildren = children.map((c, i) => {
|
|
129
129
|
return React.cloneElement(c, { data: datasets[i] });
|
|
130
130
|
});
|
|
131
131
|
const domain = {
|
|
132
|
-
x: Wrapper.getDomain(
|
|
133
|
-
|
|
132
|
+
x: Wrapper.getDomain(
|
|
133
|
+
assign({}, props, { categories }),
|
|
134
|
+
"x",
|
|
135
|
+
clonedChildren,
|
|
136
|
+
),
|
|
137
|
+
y: Wrapper.getDomain(
|
|
138
|
+
assign({}, props, { categories }),
|
|
139
|
+
"y",
|
|
140
|
+
clonedChildren,
|
|
141
|
+
),
|
|
134
142
|
};
|
|
135
143
|
const range = props.range || {
|
|
136
144
|
x: Helpers.getRange(props, "x"),
|
|
@@ -224,18 +232,18 @@ function getColorScale(props, child) {
|
|
|
224
232
|
: colorScaleOptions;
|
|
225
233
|
}
|
|
226
234
|
|
|
227
|
-
export function getChildren(
|
|
228
|
-
props = Helpers.modifyProps(
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
calculatedProps || getCalculatedProps(props,
|
|
232
|
-
const { datasets } =
|
|
233
|
-
const childProps = getChildProps(props,
|
|
235
|
+
export function getChildren(initialProps, childComponents, calculatedProps) {
|
|
236
|
+
const props = Helpers.modifyProps(initialProps, fallbackProps, "stack");
|
|
237
|
+
const children = childComponents || React.Children.toArray(props.children);
|
|
238
|
+
const newCalculatedProps =
|
|
239
|
+
calculatedProps || getCalculatedProps(props, children);
|
|
240
|
+
const { datasets } = newCalculatedProps;
|
|
241
|
+
const childProps = getChildProps(props, newCalculatedProps);
|
|
234
242
|
const parentName = props.name || "stack";
|
|
235
|
-
return
|
|
243
|
+
return children.map((child, index) => {
|
|
236
244
|
const role = child.type && child.type.role;
|
|
237
245
|
const data = datasets[index];
|
|
238
|
-
const style = Wrapper.getChildStyle(child, index,
|
|
246
|
+
const style = Wrapper.getChildStyle(child, index, newCalculatedProps);
|
|
239
247
|
const labels = props.labels
|
|
240
248
|
? getLabels(props, datasets, index)
|
|
241
249
|
: child.props.labels;
|