victory-shared-events 30.6.1 → 31.2.0
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/README.md +18 -22
- package/dist/victory-shared-events.js +1099 -851
- package/dist/victory-shared-events.min.js +1 -1
- package/es/victory-shared-events.js +10 -5
- package/lib/victory-shared-events.js +11 -5
- package/package.json +3 -2
- package/src/victory-shared-events.js +79 -71
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ The `VictorySharedEvents` wrapper coordinates events between its child component
|
|
|
20
20
|
|
|
21
21
|
The `events` prop takes an array of event objects. Event objects are composed of a `target`, an `eventKey`, a `childName` and `eventHandlers`. Targets may be any valid style namespace for a given component, so "data" and "labels" are valid targets for this components like `VictoryBar`. `eventKey` may be given as a single value, or as an array of values to specify individual targets. If `eventKey` is not specified, the given `eventHandlers` will be attached to all elements of the specified `target` type. The `childName` property may be given as a string or an array of strings to target multiple children. The `eventHandlers` object should be given as an object whose keys are standard event names (i.e. `onClick`) and whose values are event callbacks. The return value of an event handler is used to modify elements. The return value should be given as an object or an array of objects with optional `target`, `childName` and `eventKey` keys for specifying the element(s) to be modified, and a `mutation` key whose value is a function. The `target` and `eventKey` keys will default to those corresponding to the element the event handler was attached to. The `mutation` function will be called with the calculated props for each element that should be modified (i.e. a bar label), and the object returned from the mutation function will override the props of that element via object assignment.
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
_examples:_
|
|
24
24
|
|
|
25
25
|
```playground
|
|
26
26
|
<svg viewBox="0 0 450 350">
|
|
@@ -92,23 +92,19 @@ The `eventKey` prop is used to assign eventKeys to data. This prop operates iden
|
|
|
92
92
|
Occasionally is it necessary to trigger events in Victory's event system from some external element such as a button or a form field. Use the `externalEventMutation` prop to specify a set of mutations to apply to a given chart. The `externalEventMutations` should be given in the following form:
|
|
93
93
|
|
|
94
94
|
```jsx
|
|
95
|
-
externalEventMutations: PropTypes.arrayOf(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
PropTypes.string,
|
|
99
|
-
PropTypes.
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
PropTypes.
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
PropTypes.string,
|
|
109
|
-
PropTypes.array
|
|
110
|
-
])
|
|
111
|
-
}))
|
|
95
|
+
externalEventMutations: PropTypes.arrayOf(
|
|
96
|
+
PropTypes.shape({
|
|
97
|
+
callback: PropTypes.function,
|
|
98
|
+
childName: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
|
|
99
|
+
eventKey: PropTypes.oneOfType([
|
|
100
|
+
PropTypes.array,
|
|
101
|
+
CustomPropTypes.allOfType([CustomPropTypes.integer, CustomPropTypes.nonNegative]),
|
|
102
|
+
PropTypes.string
|
|
103
|
+
]),
|
|
104
|
+
mutation: PropTypes.function,
|
|
105
|
+
target: PropTypes.oneOfType([PropTypes.string, PropTypes.array])
|
|
106
|
+
})
|
|
107
|
+
);
|
|
112
108
|
```
|
|
113
109
|
|
|
114
110
|
The `target`, `eventKey`, and `childName` (when applicable) must always be specified. The `mutation` function will be called with the current props of the element specified by the `target`, `eventKey` and `childName` provided. The mutation function should return a mutation object for that element. The `callback` prop should be used to clear the `externalEventMutations` prop once the mutation has been applied. Clearing `externalEventMutations` is crucial for charts that animate.
|
|
@@ -212,8 +208,8 @@ class App extends React.Component {
|
|
|
212
208
|
ReactDOM.render(<App/>, mountNode)
|
|
213
209
|
```
|
|
214
210
|
|
|
215
|
-
|
|
211
|
+
_Note_ External mutations are applied to the same state object that is used to control events in Victory, so depending on the order in which they are triggered, external event mutations may override mutations caused by internal Victory events or vice versa.
|
|
216
212
|
|
|
217
|
-
[
|
|
218
|
-
[
|
|
219
|
-
[
|
|
213
|
+
[victorychart]: https://formidable.com/open-source/victory/docs/victory-chart
|
|
214
|
+
[victorygroup]: https://formidable.com/open-source/victory/docs/victory-group
|
|
215
|
+
[victorystack]: https://formidable.com/open-source/victory/docs/victory-stack
|