victory-group
Advanced tools
Comparing version 31.0.2 to 31.1.0
@@ -31,6 +31,3 @@ import _assign from "lodash/assign"; | ||
}); | ||
var categories = { | ||
x: Wrapper.getCategories(modifiedProps, "x"), | ||
y: Wrapper.getCategories(modifiedProps, "y") | ||
}; | ||
var categories = Wrapper.getCategories(modifiedProps, childComponents); | ||
var datasets = Wrapper.getDataFromChildren(modifiedProps); | ||
@@ -37,0 +34,0 @@ var domain = { |
@@ -46,7 +46,5 @@ "use strict"; | ||
}); | ||
var categories = { | ||
x: _victoryCore.Wrapper.getCategories(modifiedProps, "x"), | ||
y: _victoryCore.Wrapper.getCategories(modifiedProps, "y") | ||
}; | ||
var categories = _victoryCore.Wrapper.getCategories(modifiedProps, childComponents); | ||
var datasets = _victoryCore.Wrapper.getDataFromChildren(modifiedProps); | ||
@@ -53,0 +51,0 @@ |
{ | ||
"name": "victory-group", | ||
"version": "31.0.2", | ||
"version": "31.1.0", | ||
"description": "Group Layout Component for Victory", | ||
@@ -24,3 +24,3 @@ "keywords": [ | ||
"prop-types": "^15.5.8", | ||
"victory-core": "^31.0.2" | ||
"victory-core": "^31.1.0" | ||
}, | ||
@@ -27,0 +27,0 @@ "scripts": { |
@@ -1,2 +0,1 @@ | ||
# VictoryGroup | ||
@@ -92,3 +91,3 @@ | ||
*default (provided by default theme):* See [grayscale theme][] for more detail | ||
_default (provided by default theme):_ See [grayscale theme][] for more detail | ||
@@ -112,3 +111,2 @@ ```playground | ||
### containerComponent | ||
@@ -175,3 +173,3 @@ | ||
```jsx | ||
eventKey="x" | ||
eventKey = "x"; | ||
``` | ||
@@ -230,2 +228,3 @@ | ||
``` | ||
### externalEventMutations | ||
@@ -243,3 +242,3 @@ | ||
*default:* `<g/>` | ||
_default:_ `<g/>` | ||
@@ -256,3 +255,3 @@ ```jsx | ||
*default (provided by default theme):* `height={300}` | ||
_default (provided by default theme):_ `height={300}` | ||
@@ -285,3 +284,3 @@ ```jsx | ||
*default:* `<VictoryLabel/>` | ||
_default:_ `<VictoryLabel/>` | ||
@@ -311,3 +310,3 @@ ```jsx | ||
```jsx | ||
name="series-1" | ||
name = "series-1"; | ||
``` | ||
@@ -345,3 +344,2 @@ | ||
### padding | ||
@@ -353,3 +351,3 @@ | ||
*default (provided by default theme):* `padding={50}` | ||
_default (provided by default theme):_ `padding={50}` | ||
@@ -380,3 +378,3 @@ ```jsx | ||
*default:* `samples={50}` | ||
_default:_ `samples={50}` | ||
@@ -396,3 +394,3 @@ ```jsx | ||
*default:* `scale="linear"` | ||
_default:_ `scale="linear"` | ||
@@ -417,3 +415,2 @@ ```jsx | ||
`VictoryGroup` uses the standard `sortKey` prop. [Read about it here](https://formidable.com/open-source/victory/docs/common-props#sortkey) | ||
@@ -424,3 +421,3 @@ | ||
```jsx | ||
sortKey="x" | ||
sortKey = "x"; | ||
``` | ||
@@ -434,3 +431,3 @@ | ||
*default:* `sortOrder="ascending"` | ||
_default:_ `sortOrder="ascending"` | ||
@@ -445,5 +442,4 @@ ### standalone | ||
*default:* `standalone={true}` | ||
_default:_ `standalone={true}` | ||
### style | ||
@@ -457,3 +453,3 @@ | ||
*default (provided by default theme):* See [grayscale theme][] for more detail | ||
_default (provided by default theme):_ See [grayscale theme][] for more detail | ||
@@ -490,3 +486,3 @@ ```playground | ||
*default:* `theme={VictoryTheme.grayscale}` | ||
_default:_ `theme={VictoryTheme.grayscale}` | ||
@@ -503,3 +499,3 @@ ```jsx | ||
*default (provided by default theme):* `width={450}` | ||
_default (provided by default theme):_ `width={450}` | ||
@@ -519,3 +515,3 @@ ```jsx | ||
```jsx | ||
x="employee.name" | ||
x = "employee.name"; | ||
``` | ||
@@ -547,17 +543,17 @@ | ||
[Animations Guide]: https://formidable.com/open-source/victory/guides/animations | ||
[Data Accessors Guide]: https://formidable.com/open-source/victory/guides/data-accessors | ||
[Events Guide]: https://formidable.com/open-source/victory/guides/events | ||
[Themes Guide]: https://formidable.com/open-source/victory/guides/themes | ||
[animations guide]: https://formidable.com/open-source/victory/guides/animations | ||
[data accessors guide]: https://formidable.com/open-source/victory/guides/data-accessors | ||
[events guide]: https://formidable.com/open-source/victory/guides/events | ||
[themes guide]: https://formidable.com/open-source/victory/guides/themes | ||
[grayscale theme]: https://github.com/FormidableLabs/victory-core/blob/master/src/victory-theme/grayscale.js | ||
[VictoryArea]: https://formidable.com/open-source/victory/docs/victory-area | ||
[VictoryBar]: https://formidable.com/open-source/victory/docs/victory-bar | ||
[VictoryCandlestick]: https://formidable.com/open-source/victory/docs/victory-candlestick | ||
[VictoryErrorBar]: https://formidable.com/open-source/victory/docs/victory-errorbar | ||
[VictoryLine]: https://formidable.com/open-source/victory/docs/victory-line | ||
[VictoryScatter]: https://formidable.com/open-source/victory/docs/victory-scatter | ||
[VictoryStack]: https://formidable.com/open-source/victory/docs/victory-stack | ||
[VictoryVoronoi]: https://formidable.com/open-source/victory/docs/victory-voronoi | ||
[VictoryLabel]: https://formidable.com/open-source/victory/docs/victory-label | ||
[victoryarea]: https://formidable.com/open-source/victory/docs/victory-area | ||
[victorybar]: https://formidable.com/open-source/victory/docs/victory-bar | ||
[victorycandlestick]: https://formidable.com/open-source/victory/docs/victory-candlestick | ||
[victoryerrorbar]: https://formidable.com/open-source/victory/docs/victory-errorbar | ||
[victoryline]: https://formidable.com/open-source/victory/docs/victory-line | ||
[victoryscatter]: https://formidable.com/open-source/victory/docs/victory-scatter | ||
[victorystack]: https://formidable.com/open-source/victory/docs/victory-stack | ||
[victoryvoronoi]: https://formidable.com/open-source/victory/docs/victory-voronoi | ||
[victorylabel]: https://formidable.com/open-source/victory/docs/victory-label | ||
[x]: https://formidable.com/open-source/victory/docs/common-props#x | ||
[y]: https://formidable.com/open-source/victory/docs/common-props#y |
@@ -20,9 +20,6 @@ /* eslint-disable func-style */ | ||
const { offset, colorScale, color, polar } = modifiedProps; | ||
const horizontal = modifiedProps.horizontal || childComponents.every( | ||
(component) => component.props && component.props.horizontal | ||
); | ||
const categories = { | ||
x: Wrapper.getCategories(modifiedProps, "x"), | ||
y: Wrapper.getCategories(modifiedProps, "y") | ||
}; | ||
const horizontal = | ||
modifiedProps.horizontal || | ||
childComponents.every((component) => component.props && component.props.horizontal); | ||
const categories = Wrapper.getCategories(modifiedProps, childComponents); | ||
const datasets = Wrapper.getDataFromChildren(modifiedProps); | ||
@@ -51,4 +48,14 @@ const domain = { | ||
return { | ||
datasets, categories, range, domain, horizontal, | ||
scale, style, colorScale, color, offset, origin, padding | ||
datasets, | ||
categories, | ||
range, | ||
domain, | ||
horizontal, | ||
scale, | ||
style, | ||
colorScale, | ||
color, | ||
offset, | ||
origin, | ||
padding | ||
}; | ||
@@ -63,3 +70,3 @@ } | ||
const horizontalChildren = childComponents.some((child) => child.props.horizontal); | ||
const horizontal = props && props.horizontal || horizontalChildren.length > 0; | ||
const horizontal = (props && props.horizontal) || horizontalChildren.length > 0; | ||
const currentAxis = Helpers.getCurrentAxis(axis, horizontal); | ||
@@ -70,3 +77,3 @@ const domain = calculatedProps.domain[currentAxis]; | ||
const rangeExtent = Math.max(...range) - Math.min(...range); | ||
return domainExtent / rangeExtent * props.offset; | ||
return (domainExtent / rangeExtent) * props.offset; | ||
} | ||
@@ -104,3 +111,13 @@ | ||
return { | ||
height, width, theme, polar, origin, categories, domain, range, scale, horizontal, padding, | ||
height, | ||
width, | ||
theme, | ||
polar, | ||
origin, | ||
categories, | ||
domain, | ||
range, | ||
scale, | ||
horizontal, | ||
padding, | ||
standalone: false | ||
@@ -116,4 +133,5 @@ }; | ||
} | ||
return props.theme && props.theme.group ? colorScaleOptions || props.theme.group.colorScale | ||
: colorScaleOptions; | ||
return props.theme && props.theme.group | ||
? colorScaleOptions || props.theme.group.colorScale | ||
: colorScaleOptions; | ||
} | ||
@@ -125,5 +143,4 @@ | ||
return dataset.map((datum) => { | ||
const _x1 = datum._x instanceof Date | ||
? new Date(datum._x.getTime() + xOffset) | ||
: datum._x + xOffset; | ||
const _x1 = | ||
datum._x instanceof Date ? new Date(datum._x.getTime() + xOffset) : datum._x + xOffset; | ||
@@ -144,15 +161,27 @@ return assign({}, datum, { _x1 }); | ||
const role = child.type && child.type.role; | ||
const xOffset = polar ? | ||
getPolarX0(props, calculatedProps, index) : getX0(props, calculatedProps, index); | ||
const style = role === "voronoi" || role === "tooltip" || role === "label" ? | ||
child.props.style : Wrapper.getChildStyle(child, index, calculatedProps); | ||
const xOffset = polar | ||
? getPolarX0(props, calculatedProps, index) | ||
: getX0(props, calculatedProps, index); | ||
const style = | ||
role === "voronoi" || role === "tooltip" || role === "label" | ||
? child.props.style | ||
: Wrapper.getChildStyle(child, index, calculatedProps); | ||
const labels = props.labels ? getLabels(props, datasets, index) : child.props.labels; | ||
const name = child.props.name || `${parentName}-${role}-${index}`; | ||
return React.cloneElement(child, assign({ | ||
labels, style, key: `${name}-key-${index}`, name, | ||
data: getDataWithOffset(props, datasets[index], xOffset), | ||
colorScale: getColorScale(props, child), | ||
labelComponent: labelComponent || child.props.labelComponent, | ||
xOffset: role === "stack" ? xOffset : undefined | ||
}, childProps)); | ||
return React.cloneElement( | ||
child, | ||
assign( | ||
{ | ||
labels, | ||
style, | ||
key: `${name}-key-${index}`, | ||
name, | ||
data: getDataWithOffset(props, datasets[index], xOffset), | ||
colorScale: getColorScale(props, child), | ||
labelComponent: labelComponent || child.props.labelComponent, | ||
xOffset: role === "stack" ? xOffset : undefined | ||
}, | ||
childProps | ||
) | ||
); | ||
}); | ||
@@ -159,0 +188,0 @@ } |
import { assign, defaults } from "lodash"; | ||
import PropTypes from "prop-types"; | ||
import React from "react"; | ||
import { | ||
Helpers, VictoryContainer, VictoryTheme, CommonProps, Wrapper | ||
} from "victory-core"; | ||
import { Helpers, VictoryContainer, VictoryTheme, CommonProps, Wrapper } from "victory-core"; | ||
import { VictorySharedEvents } from "victory-shared-events"; | ||
@@ -30,3 +28,10 @@ import { getChildren, getCalculatedProps } from "./helper-methods"; | ||
PropTypes.oneOf([ | ||
"grayscale", "qualitative", "heatmap", "warm", "cool", "red", "green", "blue" | ||
"grayscale", | ||
"qualitative", | ||
"heatmap", | ||
"warm", | ||
"cool", | ||
"red", | ||
"green", | ||
"blue" | ||
]) | ||
@@ -39,4 +44,4 @@ ]), | ||
static defaultProps = { | ||
containerComponent: <VictoryContainer/>, | ||
groupComponent: <g/>, | ||
containerComponent: <VictoryContainer />, | ||
groupComponent: <g />, | ||
samples: 50, | ||
@@ -49,5 +54,3 @@ scale: "linear", | ||
static expectedComponents = [ | ||
"groupComponent", "containerComponent", "labelComponent" | ||
]; | ||
static expectedComponents = ["groupComponent", "containerComponent", "labelComponent"]; | ||
@@ -80,3 +83,2 @@ static getChildren = getChildren; | ||
// the old ones were bad | ||
@@ -101,4 +103,13 @@ getNewChildren(props, childComponents, calculatedProps) { | ||
return { | ||
domain, scale, width, height, standalone, theme, style: style.parent, horizontal, | ||
polar, origin, name | ||
domain, | ||
scale, | ||
width, | ||
height, | ||
standalone, | ||
theme, | ||
style: style.parent, | ||
horizontal, | ||
polar, | ||
origin, | ||
name | ||
}; | ||
@@ -109,7 +120,11 @@ } | ||
const { role } = this.constructor; | ||
const props = this.state && this.state.nodesWillExit ? | ||
this.state.oldProps || this.props : this.props; | ||
const props = | ||
this.state && this.state.nodesWillExit ? this.state.oldProps || this.props : this.props; | ||
const modifiedProps = Helpers.modifyProps(props, fallbackProps, role); | ||
const { | ||
eventKey, containerComponent, standalone, groupComponent, externalEventMutations | ||
eventKey, | ||
containerComponent, | ||
standalone, | ||
groupComponent, | ||
externalEventMutations | ||
} = modifiedProps; | ||
@@ -120,4 +135,5 @@ const childComponents = React.Children.toArray(modifiedProps.children); | ||
const containerProps = standalone ? this.getContainerProps(modifiedProps, calculatedProps) : {}; | ||
const container = standalone ? | ||
this.renderContainer(containerComponent, containerProps) : groupComponent; | ||
const container = standalone | ||
? this.renderContainer(containerComponent, containerProps) | ||
: groupComponent; | ||
if (this.events) { | ||
@@ -124,0 +140,0 @@ return ( |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
1210892
21700
539
Updatedvictory-core@^31.1.0