victory-legend 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 +23 -24
- package/dist/victory-legend.js +1497 -1253
- package/dist/victory-legend.min.js +1 -1
- package/es/helper-methods.js +2 -1
- package/lib/helper-methods.js +3 -1
- package/package.json +2 -2
- package/src/helper-methods.js +49 -28
- package/src/victory-legend.js +75 -59
package/README.md
CHANGED
|
@@ -39,7 +39,7 @@ View these docs at https://formidable.com/open-source/victory/docs/victory-legen
|
|
|
39
39
|
|
|
40
40
|
The `borderComponent` prop takes a component instance which will be responsible for rendering a border around the legend. The new element created from the passed `borderComponent` will be provided with the following properties calculated by `VictoryLegend`: `x`, `y`, `width`, `height`, and `style`. Any of these props may be overridden by passing in props to the supplied component, or modified or ignored within the custom component itself. If a `borderComponent` is not provided, `VictoryLegend` will use its default [Border component][]. Please note that the default width and height calculated for the border component is based on _approximated_ text measurements, and may need to be adjusted.
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
_default:_ `<Border/>`
|
|
43
43
|
|
|
44
44
|
```jsx
|
|
45
45
|
borderComponent={<Border width={300}/>}
|
|
@@ -100,7 +100,7 @@ The `colorScale` prop defines a color scale to be applied to each data symbol in
|
|
|
100
100
|
|
|
101
101
|
**Note:** `VictoryLegend` only works with the `VictoryContainer` component
|
|
102
102
|
|
|
103
|
-
|
|
103
|
+
_default:_ `containerComponent={<VictoryContainer/>}`
|
|
104
104
|
|
|
105
105
|
```jsx
|
|
106
106
|
containerComponent={<VictoryContainer responsive={false}/>}
|
|
@@ -112,7 +112,7 @@ containerComponent={<VictoryContainer responsive={false}/>}
|
|
|
112
112
|
|
|
113
113
|
Specify data via the `data` prop. `VictoryLegend` expects data as an array of objects with `name` (required), `symbol`, and `labels` properties. The `data` prop must be given as an array.
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
_default:_ `data={[{ name: "Series 1" }, { name: "Series 2" }]}`
|
|
116
116
|
|
|
117
117
|
```playground
|
|
118
118
|
<VictoryLegend x={125} y={50}
|
|
@@ -137,7 +137,7 @@ Specify data via the `data` prop. `VictoryLegend` expects data as an array of ob
|
|
|
137
137
|
|
|
138
138
|
See the [Custom Components Guide][] for more detail on creating your own `dataComponents`
|
|
139
139
|
|
|
140
|
-
|
|
140
|
+
_default:_ `<Point/>`
|
|
141
141
|
|
|
142
142
|
```jsx
|
|
143
143
|
dataComponent={<Point events={{ onClick: handleClick }}/>}
|
|
@@ -150,7 +150,7 @@ dataComponent={<Point events={{ onClick: handleClick }}/>}
|
|
|
150
150
|
`VictoryLegend` uses the standard `eventKey` prop to specify how event targets are addressed. **This prop is not commonly used.** [Read about the `eventKey` prop in more detail here](https://formidable.com/open-source/victory/docs/common-props#eventkey)
|
|
151
151
|
|
|
152
152
|
```jsx
|
|
153
|
-
eventKey="x"
|
|
153
|
+
eventKey = "x";
|
|
154
154
|
```
|
|
155
155
|
|
|
156
156
|
### events
|
|
@@ -205,7 +205,7 @@ See the [Events Guide][] for more information on defining events.
|
|
|
205
205
|
|
|
206
206
|
`VictoryLegend` uses the standard `groupComponent` prop. [Read about it here](https://formidable.com/open-source/victory/docs/common-props#groupcomponent)
|
|
207
207
|
|
|
208
|
-
|
|
208
|
+
_default:_ `<g/>`
|
|
209
209
|
|
|
210
210
|
```jsx
|
|
211
211
|
groupComponent={<g transform="rotate(90)" />}
|
|
@@ -217,7 +217,7 @@ groupComponent={<g transform="rotate(90)" />}
|
|
|
217
217
|
|
|
218
218
|
The `gutter` prop defines the number of pixels between legend columns. This prop may be given as a number, or as an object with values specified for "left" and "right" gutters. To set spacing between rows, use the `rowGutter` prop.
|
|
219
219
|
|
|
220
|
-
|
|
220
|
+
_default:_ `gutter={10}`
|
|
221
221
|
|
|
222
222
|
```playground
|
|
223
223
|
<VictoryLegend x={125} y={50}
|
|
@@ -236,7 +236,7 @@ The `gutter` prop defines the number of pixels between legend columns. This prop
|
|
|
236
236
|
|
|
237
237
|
`VictoryLegend` uses the standard `height` prop. [Read about it here](https://formidable.com/open-source/victory/docs/common-props#height)
|
|
238
238
|
|
|
239
|
-
|
|
239
|
+
_default (provided by default theme):_ `height={400}`
|
|
240
240
|
|
|
241
241
|
```jsx
|
|
242
242
|
height={400}
|
|
@@ -266,7 +266,7 @@ The `itemsPerRow` prop determines how many items to render in each row of a hori
|
|
|
266
266
|
|
|
267
267
|
`VictoryLegend` uses the standard `labelComponent` prop. [Read about it here](https://formidable.com/open-source/victory/docs/common-props#labelcomponent)
|
|
268
268
|
|
|
269
|
-
|
|
269
|
+
_default:_ `<VictoryLabel/>`
|
|
270
270
|
|
|
271
271
|
```playground
|
|
272
272
|
<VictoryLegend
|
|
@@ -283,7 +283,7 @@ The `itemsPerRow` prop determines how many items to render in each row of a hori
|
|
|
283
283
|
|
|
284
284
|
The `orientation` prop takes a string that defines whether legend data are displayed in a row or column. When `orientation` is `"horizontal"`, legend items will be displayed in rows. When `orientation` is `"vertical"`, legend items will be displayed in columns.
|
|
285
285
|
|
|
286
|
-
|
|
286
|
+
_default:_ `orientation="vertical"`
|
|
287
287
|
|
|
288
288
|
### padding
|
|
289
289
|
|
|
@@ -291,7 +291,7 @@ The `orientation` prop takes a string that defines whether legend data are displ
|
|
|
291
291
|
|
|
292
292
|
`VictoryLegend` uses the standard `padding` prop. [Read about it here](https://formidable.com/open-source/victory/docs/common-props#padding)
|
|
293
293
|
|
|
294
|
-
|
|
294
|
+
_default (provided by default theme):_ `padding={50}`
|
|
295
295
|
|
|
296
296
|
```jsx
|
|
297
297
|
padding={{ top: 20, bottom: 60 }}
|
|
@@ -326,7 +326,7 @@ The `rowGutter` prop defines the number of pixels between legend rows. This prop
|
|
|
326
326
|
|
|
327
327
|
The `standalone` props specifies whether the component should be rendered in an independent `<svg>` element or in a `<g>` tag. This prop defaults to true, and renders an `svg`.
|
|
328
328
|
|
|
329
|
-
|
|
329
|
+
_default:_ `standalone={true}`
|
|
330
330
|
|
|
331
331
|
### style
|
|
332
332
|
|
|
@@ -338,7 +338,7 @@ The `style` prop defines the style of the component. The style prop should be gi
|
|
|
338
338
|
|
|
339
339
|
**note:** custom `angle` and `verticalAnchor` properties may be included in `labels` and `title` styles.
|
|
340
340
|
|
|
341
|
-
|
|
341
|
+
_default (provided by default theme):_ See [grayscale theme][] for more detail
|
|
342
342
|
|
|
343
343
|
```playground
|
|
344
344
|
<VictoryLegend x={125} y={50}
|
|
@@ -383,7 +383,7 @@ The `symbolSpacer` prop defines the number of pixels between data components and
|
|
|
383
383
|
|
|
384
384
|
The `theme` prop specifies a theme to use for determining styles and layout properties for a component. Any styles or props defined in `theme` may be overridden by props specified on the component instance. By default, components use a [grayscale theme][]. [Read more about themes here][].
|
|
385
385
|
|
|
386
|
-
|
|
386
|
+
_default:_ `theme={VictoryTheme.grayscale}`
|
|
387
387
|
|
|
388
388
|
### title
|
|
389
389
|
|
|
@@ -409,8 +409,7 @@ The `title` prop specifies a title to render with the legend. This prop should b
|
|
|
409
409
|
|
|
410
410
|
The `titleComponent` prop takes a component instance which will be used to render a title for the component. The new element created from the passed `labelComponent` will be supplied with the following properties: `x`, `y`, `index`, `data`, `datum`, `verticalAnchor`, `textAnchor`, `style`, `text`, and `events`. Any of these props may be overridden by passing in props to the supplied component, or modified or ignored within the custom component itself. If `labelComponent` is omitted, a new [VictoryLabel][] will be created with the props described above.
|
|
411
411
|
|
|
412
|
-
|
|
413
|
-
|
|
412
|
+
_default:_ `<VictoryLabel/>`
|
|
414
413
|
|
|
415
414
|
```playground
|
|
416
415
|
<VictoryLegend x={125} y={50}
|
|
@@ -431,7 +430,7 @@ The `titleComponent` prop takes a component instance which will be used to rende
|
|
|
431
430
|
|
|
432
431
|
The `titleOrientation` prop specifies where the a title should be rendered in relation to the rest of the legend. Possible values for this prop are "top", "bottom", "left", and "right".
|
|
433
432
|
|
|
434
|
-
|
|
433
|
+
_default (provided by default theme):_ `titleOrientation="top"`
|
|
435
434
|
|
|
436
435
|
```playground
|
|
437
436
|
<VictoryLegend x={50} y={50}
|
|
@@ -452,7 +451,7 @@ The `titleOrientation` prop specifies where the a title should be rendered in re
|
|
|
452
451
|
|
|
453
452
|
`VictoryLegend` uses the standard `width` prop. [Read about it here](https://formidable.com/open-source/victory/docs/common-props#width)
|
|
454
453
|
|
|
455
|
-
|
|
454
|
+
_default (provided by default theme):_ `width={400}`
|
|
456
455
|
|
|
457
456
|
```jsx
|
|
458
457
|
width={400}
|
|
@@ -470,10 +469,10 @@ The `x` prop defines the x coordinate corresponding to the upper left corner of
|
|
|
470
469
|
|
|
471
470
|
The `y` prop defines the y coordinate corresponding to the upper left corner of the legend.
|
|
472
471
|
|
|
473
|
-
[
|
|
474
|
-
[
|
|
475
|
-
[
|
|
472
|
+
[victorylabel]: https://formidable.com/open-source/victory/docs/victory-label
|
|
473
|
+
[point component]: https://formidable.com/open-source/victory/docs/victory-primitives#point
|
|
474
|
+
[border component]: https://formidable.com/open-source/victory/docs/victory-primitives#border
|
|
476
475
|
[grayscale theme]: https://github.com/FormidableLabs/victory-core/blob/master/src/victory-theme/grayscale.js
|
|
477
|
-
[
|
|
478
|
-
[
|
|
479
|
-
[
|
|
476
|
+
[read more about themes here]: https://formidable.com/open-source/victory/guides/themes
|
|
477
|
+
[custom components guide]: https://formidable.com/open-source/victory/guides/custom-components
|
|
478
|
+
[events guide]: https://formidable.com/open-source/victory/guides/events
|