victory-core 37.1.2 → 37.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/CHANGELOG.md +12 -0
- package/dist/victory-core.js +205 -72
- package/dist/victory-core.min.js +1 -1
- package/es/types/prop-types.d.ts +1 -0
- package/es/victory-portal/victory-portal.js +2 -1
- package/es/victory-theme/clean.js +77 -32
- package/es/victory-theme/grayscale.js +36 -6
- package/es/victory-theme/material.js +36 -5
- package/es/victory-theme/types.d.ts +16 -0
- package/es/victory-util/style.d.ts +3 -1
- package/es/victory-util/style.js +29 -10
- package/es/victory-util/wrapper.d.ts +2 -2
- package/es/victory-util/wrapper.js +8 -4
- package/lib/types/prop-types.d.ts +1 -0
- package/lib/victory-portal/victory-portal.js +2 -1
- package/lib/victory-theme/clean.js +77 -32
- package/lib/victory-theme/grayscale.js +36 -6
- package/lib/victory-theme/material.js +36 -5
- package/lib/victory-theme/types.d.ts +16 -0
- package/lib/victory-util/style.d.ts +3 -1
- package/lib/victory-util/style.js +28 -10
- package/lib/victory-util/wrapper.d.ts +2 -2
- package/lib/victory-util/wrapper.js +8 -4
- package/package.json +2 -2
- package/src/types/prop-types.ts +1 -0
- package/src/victory-portal/victory-portal.tsx +2 -2
- package/src/victory-theme/clean.tsx +76 -39
- package/src/victory-theme/grayscale.tsx +49 -6
- package/src/victory-theme/material.tsx +50 -6
- package/src/victory-theme/types.ts +26 -0
- package/src/victory-util/style.ts +37 -22
- package/src/victory-util/wrapper.tsx +8 -4
package/es/types/prop-types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _uniqueId from "lodash/uniqueId";
|
|
1
2
|
import _defaults from "lodash/defaults";
|
|
2
3
|
import React from "react";
|
|
3
4
|
import * as Log from "../victory-util/log";
|
|
@@ -11,7 +12,7 @@ export const VictoryPortal = initialProps => {
|
|
|
11
12
|
...defaultProps,
|
|
12
13
|
...initialProps
|
|
13
14
|
};
|
|
14
|
-
const id =
|
|
15
|
+
const id = _uniqueId();
|
|
15
16
|
const portalContext = usePortalContext();
|
|
16
17
|
if (!portalContext) {
|
|
17
18
|
const msg = "`renderInPortal` is not supported outside of `VictoryContainer`. " + "Component will be rendered in place";
|
|
@@ -70,7 +70,26 @@ const green = {
|
|
|
70
70
|
"500": "#20C933",
|
|
71
71
|
"900": "#338A17"
|
|
72
72
|
};
|
|
73
|
-
const colors =
|
|
73
|
+
const colors = {
|
|
74
|
+
blue: blue["500"],
|
|
75
|
+
pink: pink["500"],
|
|
76
|
+
teal: teal["500"],
|
|
77
|
+
purple: purple["500"],
|
|
78
|
+
green: green["500"],
|
|
79
|
+
orange: orange["500"],
|
|
80
|
+
cyan: cyan["500"],
|
|
81
|
+
red: red["500"],
|
|
82
|
+
yellow: yellow["500"]
|
|
83
|
+
};
|
|
84
|
+
const colorScale = Object.values(colors);
|
|
85
|
+
const grayscale = [gray["200"], gray["400"], gray["600"], gray["900"]];
|
|
86
|
+
const warm = [yellow["500"], orange["500"], red["500"], pink["500"]];
|
|
87
|
+
const cool = [cyan["500"], teal["500"], blue["500"], purple["500"]];
|
|
88
|
+
const heatmap = [green["500"], yellow["500"], red["500"]];
|
|
89
|
+
const redPalette = [red["500"], red["300"], red["100"]];
|
|
90
|
+
const greenPalette = [green["500"], green["300"], green["100"]];
|
|
91
|
+
const bluePalette = [blue["500"], blue["300"], blue["100"]];
|
|
92
|
+
|
|
74
93
|
// *
|
|
75
94
|
// * Typography
|
|
76
95
|
// *
|
|
@@ -85,7 +104,7 @@ const baseProps = {
|
|
|
85
104
|
width: 450,
|
|
86
105
|
height: 300,
|
|
87
106
|
padding: 50,
|
|
88
|
-
colorScale
|
|
107
|
+
colorScale
|
|
89
108
|
};
|
|
90
109
|
// *
|
|
91
110
|
// * Labels
|
|
@@ -114,10 +133,23 @@ const borderRadius = 1;
|
|
|
114
133
|
// * Theme
|
|
115
134
|
// *
|
|
116
135
|
export const clean = {
|
|
136
|
+
palette: {
|
|
137
|
+
colors,
|
|
138
|
+
grayscale,
|
|
139
|
+
qualitative: colorScale,
|
|
140
|
+
heatmap,
|
|
141
|
+
warm,
|
|
142
|
+
cool,
|
|
143
|
+
red: redPalette,
|
|
144
|
+
green: greenPalette,
|
|
145
|
+
blue: bluePalette
|
|
146
|
+
},
|
|
117
147
|
area: Object.assign({
|
|
118
148
|
style: {
|
|
119
149
|
data: {
|
|
120
|
-
fill:
|
|
150
|
+
fill: blue["500"],
|
|
151
|
+
strokeWidth: 2,
|
|
152
|
+
fillOpacity: 0.5
|
|
121
153
|
},
|
|
122
154
|
labels: baseLabelStyles
|
|
123
155
|
}
|
|
@@ -126,7 +158,7 @@ export const clean = {
|
|
|
126
158
|
style: {
|
|
127
159
|
axis: {
|
|
128
160
|
fill: "transparent",
|
|
129
|
-
stroke: gray["
|
|
161
|
+
stroke: gray["500"],
|
|
130
162
|
strokeWidth: 1,
|
|
131
163
|
strokeLinecap,
|
|
132
164
|
strokeLinejoin
|
|
@@ -151,10 +183,10 @@ export const clean = {
|
|
|
151
183
|
polarAxis: Object.assign({
|
|
152
184
|
style: {
|
|
153
185
|
axis: {
|
|
154
|
-
stroke: gray["
|
|
186
|
+
stroke: gray["500"]
|
|
155
187
|
},
|
|
156
188
|
grid: {
|
|
157
|
-
stroke: gray["
|
|
189
|
+
stroke: gray["400"],
|
|
158
190
|
strokeDasharray,
|
|
159
191
|
strokeLinecap,
|
|
160
192
|
strokeLinejoin,
|
|
@@ -163,7 +195,7 @@ export const clean = {
|
|
|
163
195
|
ticks: {
|
|
164
196
|
fill: "transparent",
|
|
165
197
|
size: 5,
|
|
166
|
-
stroke: gray["
|
|
198
|
+
stroke: gray["400"],
|
|
167
199
|
strokeWidth: 1,
|
|
168
200
|
strokeLinecap,
|
|
169
201
|
strokeLinejoin
|
|
@@ -174,10 +206,10 @@ export const clean = {
|
|
|
174
206
|
polarDependentAxis: Object.assign({
|
|
175
207
|
style: {
|
|
176
208
|
axis: {
|
|
177
|
-
stroke: gray["
|
|
209
|
+
stroke: gray["500"]
|
|
178
210
|
},
|
|
179
211
|
grid: {
|
|
180
|
-
stroke: gray["
|
|
212
|
+
stroke: gray["400"],
|
|
181
213
|
strokeDasharray,
|
|
182
214
|
strokeLinecap,
|
|
183
215
|
strokeLinejoin,
|
|
@@ -186,7 +218,7 @@ export const clean = {
|
|
|
186
218
|
ticks: {
|
|
187
219
|
fill: "transparent",
|
|
188
220
|
size: 5,
|
|
189
|
-
stroke: gray["
|
|
221
|
+
stroke: gray["300"],
|
|
190
222
|
strokeWidth: 1,
|
|
191
223
|
strokeLinecap,
|
|
192
224
|
strokeLinejoin
|
|
@@ -199,7 +231,8 @@ export const clean = {
|
|
|
199
231
|
data: {
|
|
200
232
|
fill: blue["500"],
|
|
201
233
|
padding,
|
|
202
|
-
strokeWidth:
|
|
234
|
+
strokeWidth: 1,
|
|
235
|
+
fillOpacity: 0.5
|
|
203
236
|
},
|
|
204
237
|
labels: baseLabelStyles
|
|
205
238
|
},
|
|
@@ -236,14 +269,15 @@ export const clean = {
|
|
|
236
269
|
q1: {
|
|
237
270
|
padding,
|
|
238
271
|
fill: teal["500"],
|
|
239
|
-
rx: borderRadius
|
|
272
|
+
rx: borderRadius,
|
|
273
|
+
strokeWidth: 2
|
|
240
274
|
},
|
|
241
275
|
q1Labels: Object.assign({}, baseLabelStyles, {
|
|
242
276
|
padding: 3
|
|
243
277
|
}),
|
|
244
278
|
q3: {
|
|
245
279
|
padding,
|
|
246
|
-
fill:
|
|
280
|
+
fill: cyan["500"],
|
|
247
281
|
rx: borderRadius
|
|
248
282
|
},
|
|
249
283
|
q3Labels: Object.assign({}, baseLabelStyles, {
|
|
@@ -284,14 +318,13 @@ export const clean = {
|
|
|
284
318
|
}
|
|
285
319
|
}, baseProps),
|
|
286
320
|
group: Object.assign({
|
|
287
|
-
colorScale
|
|
321
|
+
colorScale
|
|
288
322
|
}, baseProps),
|
|
289
323
|
histogram: Object.assign({
|
|
290
324
|
style: {
|
|
291
325
|
data: {
|
|
292
326
|
fill: cyan["500"],
|
|
293
|
-
|
|
294
|
-
strokeWidth: 0
|
|
327
|
+
fillOpacity: 0.5
|
|
295
328
|
},
|
|
296
329
|
labels: baseLabelStyles
|
|
297
330
|
},
|
|
@@ -302,21 +335,23 @@ export const clean = {
|
|
|
302
335
|
}, baseProps),
|
|
303
336
|
label: baseLabelStyles,
|
|
304
337
|
legend: {
|
|
305
|
-
colorScale
|
|
306
|
-
gutter:
|
|
307
|
-
|
|
338
|
+
colorScale,
|
|
339
|
+
gutter: 24,
|
|
340
|
+
borderPadding: 10,
|
|
341
|
+
orientation: "horizontal",
|
|
308
342
|
titleOrientation: "top",
|
|
343
|
+
centerTitle: true,
|
|
309
344
|
style: {
|
|
310
345
|
data: {
|
|
311
346
|
type: "circle"
|
|
312
347
|
},
|
|
313
348
|
labels: {
|
|
314
349
|
...baseLabelStyles,
|
|
315
|
-
fontSize:
|
|
350
|
+
fontSize: 12
|
|
316
351
|
},
|
|
317
352
|
title: Object.assign({}, baseLabelStyles, {
|
|
318
353
|
padding,
|
|
319
|
-
fontSize:
|
|
354
|
+
fontSize: 16
|
|
320
355
|
}),
|
|
321
356
|
border: {
|
|
322
357
|
stroke: gray["200"],
|
|
@@ -330,7 +365,7 @@ export const clean = {
|
|
|
330
365
|
data: {
|
|
331
366
|
fill: "transparent",
|
|
332
367
|
opacity: 1,
|
|
333
|
-
stroke:
|
|
368
|
+
stroke: blue["500"],
|
|
334
369
|
strokeWidth: 2,
|
|
335
370
|
strokeLinecap,
|
|
336
371
|
strokeLinejoin
|
|
@@ -340,16 +375,22 @@ export const clean = {
|
|
|
340
375
|
}, baseProps),
|
|
341
376
|
pie: Object.assign({
|
|
342
377
|
style: {
|
|
378
|
+
parent: {
|
|
379
|
+
backgroundColor: gray.white
|
|
380
|
+
},
|
|
343
381
|
data: {
|
|
344
382
|
padding,
|
|
345
383
|
stroke: gray.white,
|
|
346
384
|
strokeWidth: 1
|
|
347
385
|
},
|
|
348
|
-
labels:
|
|
349
|
-
|
|
350
|
-
|
|
386
|
+
labels: {
|
|
387
|
+
...baseLabelStyles,
|
|
388
|
+
padding: 20,
|
|
389
|
+
fill: gray["600"],
|
|
390
|
+
fontSize: 10
|
|
391
|
+
}
|
|
351
392
|
},
|
|
352
|
-
colorScale
|
|
393
|
+
colorScale,
|
|
353
394
|
cornerRadius: borderRadius
|
|
354
395
|
}, baseProps),
|
|
355
396
|
scatter: Object.assign({
|
|
@@ -360,11 +401,14 @@ export const clean = {
|
|
|
360
401
|
stroke: "transparent",
|
|
361
402
|
strokeWidth: 0
|
|
362
403
|
},
|
|
363
|
-
labels:
|
|
404
|
+
labels: {
|
|
405
|
+
...baseLabelStyles,
|
|
406
|
+
padding: 20
|
|
407
|
+
}
|
|
364
408
|
}
|
|
365
409
|
}, baseProps),
|
|
366
410
|
stack: Object.assign({
|
|
367
|
-
colorScale
|
|
411
|
+
colorScale
|
|
368
412
|
}, baseProps),
|
|
369
413
|
tooltip: {
|
|
370
414
|
style: Object.assign({}, baseLabelStyles, {
|
|
@@ -372,7 +416,7 @@ export const clean = {
|
|
|
372
416
|
pointerEvents: "none"
|
|
373
417
|
}),
|
|
374
418
|
flyoutStyle: {
|
|
375
|
-
stroke: gray["
|
|
419
|
+
stroke: gray["300"],
|
|
376
420
|
strokeWidth: 2,
|
|
377
421
|
fill: gray.white,
|
|
378
422
|
pointerEvents: "none"
|
|
@@ -389,9 +433,10 @@ export const clean = {
|
|
|
389
433
|
voronoi: Object.assign({
|
|
390
434
|
style: {
|
|
391
435
|
data: {
|
|
392
|
-
fill:
|
|
393
|
-
stroke:
|
|
394
|
-
strokeWidth: 2
|
|
436
|
+
fill: blue["100"],
|
|
437
|
+
stroke: blue["500"],
|
|
438
|
+
strokeWidth: 2,
|
|
439
|
+
opacity: 0.4
|
|
395
440
|
},
|
|
396
441
|
labels: Object.assign({}, baseLabelStyles, {
|
|
397
442
|
padding: 5,
|
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
// *
|
|
2
2
|
// * Colors
|
|
3
3
|
// *
|
|
4
|
-
const colors =
|
|
4
|
+
const colors = {
|
|
5
|
+
blue: "#4F7DA1",
|
|
6
|
+
pink: "#E2A37F",
|
|
7
|
+
teal: "#00796B",
|
|
8
|
+
purple: "#DF948A",
|
|
9
|
+
green: "#8BC34A",
|
|
10
|
+
orange: "#F4511E",
|
|
11
|
+
cyan: "#006064",
|
|
12
|
+
red: "#DF5A49",
|
|
13
|
+
yellow: "#FFF59D"
|
|
14
|
+
};
|
|
15
|
+
const colorScale = ["#252525", "#525252", "#737373", "#969696", "#bdbdbd", "#d9d9d9", "#f0f0f0"];
|
|
5
16
|
const charcoal = "#252525";
|
|
6
17
|
const grey = "#969696";
|
|
18
|
+
const qualitative = ["#334D5C", "#45B29D", "#EFC94C", "#E27A3F", "#DF5A49", "#4F7DA1", "#55DBC1", "#EFDA97", "#E2A37F", "#DF948A"];
|
|
19
|
+
const heatmap = ["#428517", "#77D200", "#D6D305", "#EC8E19", "#C92B05"];
|
|
20
|
+
const warm = ["#940031", "#C43343", "#DC5429", "#FF821D", "#FFAF55"];
|
|
21
|
+
const cool = ["#2746B9", "#0B69D4", "#2794DB", "#31BB76", "#60E83B"];
|
|
22
|
+
const red = ["#FCAE91", "#FB6A4A", "#DE2D26", "#A50F15", "#750B0E"];
|
|
23
|
+
const green = ["#354722", "#466631", "#649146", "#8AB25C", "#A9C97E"];
|
|
24
|
+
const blue = ["#002C61", "#004B8F", "#006BC9", "#3795E5", "#65B4F4"];
|
|
25
|
+
|
|
7
26
|
// *
|
|
8
27
|
// * Typography
|
|
9
28
|
// *
|
|
@@ -17,7 +36,7 @@ const baseProps = {
|
|
|
17
36
|
width: 450,
|
|
18
37
|
height: 300,
|
|
19
38
|
padding: 50,
|
|
20
|
-
colorScale
|
|
39
|
+
colorScale
|
|
21
40
|
};
|
|
22
41
|
// *
|
|
23
42
|
// * Labels
|
|
@@ -39,6 +58,17 @@ const centeredLabelStyles = Object.assign({
|
|
|
39
58
|
const strokeLinecap = "round";
|
|
40
59
|
const strokeLinejoin = "round";
|
|
41
60
|
export const grayscale = {
|
|
61
|
+
palette: {
|
|
62
|
+
colors,
|
|
63
|
+
grayscale: colorScale,
|
|
64
|
+
qualitative,
|
|
65
|
+
heatmap,
|
|
66
|
+
warm,
|
|
67
|
+
cool,
|
|
68
|
+
red,
|
|
69
|
+
green,
|
|
70
|
+
blue
|
|
71
|
+
},
|
|
42
72
|
area: Object.assign({
|
|
43
73
|
style: {
|
|
44
74
|
data: {
|
|
@@ -153,7 +183,7 @@ export const grayscale = {
|
|
|
153
183
|
}
|
|
154
184
|
}, baseProps),
|
|
155
185
|
group: Object.assign({
|
|
156
|
-
colorScale
|
|
186
|
+
colorScale
|
|
157
187
|
}, baseProps),
|
|
158
188
|
histogram: Object.assign({
|
|
159
189
|
style: {
|
|
@@ -166,7 +196,7 @@ export const grayscale = {
|
|
|
166
196
|
}
|
|
167
197
|
}, baseProps),
|
|
168
198
|
legend: {
|
|
169
|
-
colorScale
|
|
199
|
+
colorScale,
|
|
170
200
|
gutter: 10,
|
|
171
201
|
orientation: "vertical",
|
|
172
202
|
titleOrientation: "top",
|
|
@@ -201,7 +231,7 @@ export const grayscale = {
|
|
|
201
231
|
padding: 20
|
|
202
232
|
})
|
|
203
233
|
},
|
|
204
|
-
colorScale
|
|
234
|
+
colorScale,
|
|
205
235
|
width: 400,
|
|
206
236
|
height: 400,
|
|
207
237
|
padding: 50
|
|
@@ -217,7 +247,7 @@ export const grayscale = {
|
|
|
217
247
|
}
|
|
218
248
|
}, baseProps),
|
|
219
249
|
stack: Object.assign({
|
|
220
|
-
colorScale
|
|
250
|
+
colorScale
|
|
221
251
|
}, baseProps),
|
|
222
252
|
tooltip: {
|
|
223
253
|
style: Object.assign({}, baseLabelStyles, {
|
|
@@ -7,11 +7,31 @@ const lime300 = "#DCE775";
|
|
|
7
7
|
const lightGreen500 = "#8BC34A";
|
|
8
8
|
const teal700 = "#00796B";
|
|
9
9
|
const cyan900 = "#006064";
|
|
10
|
-
const
|
|
10
|
+
const colorScale = [deepOrange600, yellow200, lime300, lightGreen500, teal700, cyan900];
|
|
11
11
|
const blueGrey50 = "#ECEFF1";
|
|
12
12
|
const blueGrey300 = "#90A4AE";
|
|
13
13
|
const blueGrey700 = "#455A64";
|
|
14
14
|
const grey900 = "#212121";
|
|
15
|
+
const colors = {
|
|
16
|
+
blue: "#4F7DA1",
|
|
17
|
+
pink: "#E2A37F",
|
|
18
|
+
teal: teal700,
|
|
19
|
+
purple: "#DF948A",
|
|
20
|
+
green: lightGreen500,
|
|
21
|
+
orange: deepOrange600,
|
|
22
|
+
cyan: cyan900,
|
|
23
|
+
red: "#DF5A49",
|
|
24
|
+
yellow: yellow200
|
|
25
|
+
};
|
|
26
|
+
const grayscale = [blueGrey50, blueGrey300, blueGrey700, grey900];
|
|
27
|
+
const qualitative = ["#334D5C", "#45B29D", "#EFC94C", "#E27A3F", "#DF5A49", "#4F7DA1", "#55DBC1", "#EFDA97", "#E2A37F", "#DF948A"];
|
|
28
|
+
const heatmap = ["#428517", "#77D200", "#D6D305", "#EC8E19", "#C92B05"];
|
|
29
|
+
const warm = ["#940031", "#C43343", "#DC5429", "#FF821D", "#FFAF55"];
|
|
30
|
+
const cool = ["#2746B9", "#0B69D4", "#2794DB", "#31BB76", "#60E83B"];
|
|
31
|
+
const red = ["#FCAE91", "#FB6A4A", "#DE2D26", "#A50F15", "#750B0E"];
|
|
32
|
+
const green = ["#354722", "#466631", "#649146", "#8AB25C", "#A9C97E"];
|
|
33
|
+
const blue = ["#002C61", "#004B8F", "#006BC9", "#3795E5", "#65B4F4"];
|
|
34
|
+
|
|
15
35
|
// *
|
|
16
36
|
// * Typography
|
|
17
37
|
// *
|
|
@@ -49,6 +69,17 @@ const strokeDasharray = "10, 5";
|
|
|
49
69
|
const strokeLinecap = "round";
|
|
50
70
|
const strokeLinejoin = "round";
|
|
51
71
|
export const material = {
|
|
72
|
+
palette: {
|
|
73
|
+
colors,
|
|
74
|
+
grayscale,
|
|
75
|
+
qualitative,
|
|
76
|
+
heatmap,
|
|
77
|
+
warm,
|
|
78
|
+
cool,
|
|
79
|
+
red,
|
|
80
|
+
green,
|
|
81
|
+
blue
|
|
82
|
+
},
|
|
52
83
|
area: Object.assign({
|
|
53
84
|
style: {
|
|
54
85
|
data: {
|
|
@@ -181,7 +212,7 @@ export const material = {
|
|
|
181
212
|
}
|
|
182
213
|
}, baseProps),
|
|
183
214
|
group: Object.assign({
|
|
184
|
-
colorScale
|
|
215
|
+
colorScale
|
|
185
216
|
}, baseProps),
|
|
186
217
|
histogram: Object.assign({
|
|
187
218
|
style: {
|
|
@@ -194,7 +225,7 @@ export const material = {
|
|
|
194
225
|
}
|
|
195
226
|
}, baseProps),
|
|
196
227
|
legend: {
|
|
197
|
-
colorScale
|
|
228
|
+
colorScale,
|
|
198
229
|
gutter: 10,
|
|
199
230
|
orientation: "vertical",
|
|
200
231
|
titleOrientation: "top",
|
|
@@ -220,7 +251,7 @@ export const material = {
|
|
|
220
251
|
}
|
|
221
252
|
}, baseProps),
|
|
222
253
|
pie: Object.assign({
|
|
223
|
-
colorScale
|
|
254
|
+
colorScale,
|
|
224
255
|
style: {
|
|
225
256
|
data: {
|
|
226
257
|
padding,
|
|
@@ -244,7 +275,7 @@ export const material = {
|
|
|
244
275
|
}
|
|
245
276
|
}, baseProps),
|
|
246
277
|
stack: Object.assign({
|
|
247
|
-
colorScale
|
|
278
|
+
colorScale
|
|
248
279
|
}, baseProps),
|
|
249
280
|
tooltip: {
|
|
250
281
|
style: Object.assign({}, baseLabelStyles, {
|
|
@@ -59,7 +59,22 @@ export interface VictoryAxisCommonProps {
|
|
|
59
59
|
tickValues?: any[];
|
|
60
60
|
}
|
|
61
61
|
export declare type VerticalAnchorType = "start" | "middle" | "end";
|
|
62
|
+
declare type VictoryThemePaletteKeys = "blue" | "pink" | "teal" | "purple" | "green" | "orange" | "cyan" | "red" | "yellow";
|
|
63
|
+
export declare type VictoryThemePalette = {
|
|
64
|
+
[key in VictoryThemePaletteKeys]?: string;
|
|
65
|
+
};
|
|
62
66
|
export interface VictoryThemeDefinition {
|
|
67
|
+
palette?: {
|
|
68
|
+
colors?: VictoryThemePalette;
|
|
69
|
+
grayscale?: string[];
|
|
70
|
+
qualitative?: string[];
|
|
71
|
+
heatmap?: string[];
|
|
72
|
+
warm?: string[];
|
|
73
|
+
cool?: string[];
|
|
74
|
+
red?: string[];
|
|
75
|
+
blue?: string[];
|
|
76
|
+
green?: string[];
|
|
77
|
+
};
|
|
63
78
|
area?: {
|
|
64
79
|
style?: {
|
|
65
80
|
data?: VictoryStyleObject;
|
|
@@ -237,4 +252,5 @@ export interface VictoryThemeDefinition {
|
|
|
237
252
|
};
|
|
238
253
|
} & VictoryCommonThemeProps & VictoryDatableProps;
|
|
239
254
|
}
|
|
255
|
+
export {};
|
|
240
256
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { VictoryThemeDefinition } from "../victory-theme/victory-theme";
|
|
1
2
|
/**
|
|
2
3
|
* Given an object with CSS/SVG transform definitions, return the string value
|
|
3
4
|
* for use with the `transform` CSS property or SVG attribute. Note that we
|
|
@@ -13,7 +14,8 @@ export declare const toTransformString: (obj: any, ...more: any[]) => any;
|
|
|
13
14
|
* of 5 hex string values in that color scale. If no 'name' parameter
|
|
14
15
|
* is given, it will return the Victory default grayscale.
|
|
15
16
|
* @param {String} name The name of the color scale to return (optional).
|
|
17
|
+
* @param {Object} theme The theme object to retrieve the color scale from (optional).
|
|
16
18
|
* @returns {Array} An array of 5 hex string values composing a color scale.
|
|
17
19
|
*/
|
|
18
|
-
export declare function getColorScale(name
|
|
20
|
+
export declare function getColorScale(name?: string, theme?: VictoryThemeDefinition): string[];
|
|
19
21
|
//# sourceMappingURL=style.d.ts.map
|
package/es/victory-util/style.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { VictoryTheme } from "../victory-theme/victory-theme";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Given an object with CSS/SVG transform definitions, return the string value
|
|
3
5
|
* for use with the `transform` CSS property or SVG attribute. Note that we
|
|
@@ -34,18 +36,35 @@ export const toTransformString = function (obj) {
|
|
|
34
36
|
* of 5 hex string values in that color scale. If no 'name' parameter
|
|
35
37
|
* is given, it will return the Victory default grayscale.
|
|
36
38
|
* @param {String} name The name of the color scale to return (optional).
|
|
39
|
+
* @param {Object} theme The theme object to retrieve the color scale from (optional).
|
|
37
40
|
* @returns {Array} An array of 5 hex string values composing a color scale.
|
|
38
41
|
*/
|
|
39
|
-
export function getColorScale(name) {
|
|
42
|
+
export function getColorScale(name, theme) {
|
|
43
|
+
if (theme === void 0) {
|
|
44
|
+
theme = VictoryTheme.material;
|
|
45
|
+
}
|
|
46
|
+
const {
|
|
47
|
+
palette: {
|
|
48
|
+
grayscale = ["#cccccc", "#969696", "#636363", "#252525"],
|
|
49
|
+
qualitative = [],
|
|
50
|
+
heatmap = [],
|
|
51
|
+
warm = [],
|
|
52
|
+
cool = [],
|
|
53
|
+
red = [],
|
|
54
|
+
blue = [],
|
|
55
|
+
green = []
|
|
56
|
+
} = {}
|
|
57
|
+
} = theme;
|
|
40
58
|
const scales = {
|
|
41
|
-
grayscale
|
|
42
|
-
qualitative
|
|
43
|
-
heatmap
|
|
44
|
-
warm
|
|
45
|
-
cool
|
|
46
|
-
red
|
|
47
|
-
blue
|
|
48
|
-
green
|
|
59
|
+
grayscale,
|
|
60
|
+
qualitative,
|
|
61
|
+
heatmap,
|
|
62
|
+
warm,
|
|
63
|
+
cool,
|
|
64
|
+
red,
|
|
65
|
+
blue,
|
|
66
|
+
green
|
|
49
67
|
};
|
|
50
|
-
|
|
68
|
+
const selectedScale = name && scales[name]?.length ? scales[name] : scales.grayscale;
|
|
69
|
+
return selectedScale;
|
|
51
70
|
}
|
|
@@ -14,9 +14,9 @@ export declare function getDomainFromChildren(props: any, axis: any, childCompon
|
|
|
14
14
|
export declare function getDomain(props: any, axis: any, childComponents: any): any;
|
|
15
15
|
export declare function getScale(props: any, axis: any, childComponents?: any): import("..").D3Scale<any>;
|
|
16
16
|
export declare function getAllEvents(props: any): any;
|
|
17
|
-
export declare function getColor(calculatedProps: any, child: any, index: any): any;
|
|
17
|
+
export declare function getColor(calculatedProps: any, child: any, index: any, theme: any): any;
|
|
18
18
|
export declare function getStyle(theme: any, style: any, role: any): any;
|
|
19
|
-
export declare function getChildStyle(child: any, index: any, calculatedProps: any): any;
|
|
19
|
+
export declare function getChildStyle(child: any, index: any, calculatedProps: any, theme: any): any;
|
|
20
20
|
export declare function getStringsFromCategories(childComponents: any, axis: any): any[];
|
|
21
21
|
export declare function getStringsFromData(childComponents: any): {
|
|
22
22
|
x: number[];
|
|
@@ -254,7 +254,9 @@ export function getAllEvents(props) {
|
|
|
254
254
|
}
|
|
255
255
|
return events || [];
|
|
256
256
|
}
|
|
257
|
-
|
|
257
|
+
|
|
258
|
+
// eslint-disable-next-line max-params
|
|
259
|
+
export function getColor(calculatedProps, child, index, theme) {
|
|
258
260
|
// check for styles first
|
|
259
261
|
const {
|
|
260
262
|
style
|
|
@@ -271,14 +273,16 @@ export function getColor(calculatedProps, child, index) {
|
|
|
271
273
|
if (!colorScale && !color) {
|
|
272
274
|
return undefined;
|
|
273
275
|
}
|
|
274
|
-
const colors = Array.isArray(colorScale) ? colorScale : Style.getColorScale(colorScale);
|
|
276
|
+
const colors = Array.isArray(colorScale) ? colorScale : Style.getColorScale(colorScale, theme);
|
|
275
277
|
return color || colors[index % colors.length];
|
|
276
278
|
}
|
|
277
279
|
export function getStyle(theme, style, role) {
|
|
278
280
|
const defaultStyle = theme && theme[role] && theme[role].style ? theme[role].style : {};
|
|
279
281
|
return Helpers.getStyles(style, defaultStyle);
|
|
280
282
|
}
|
|
281
|
-
|
|
283
|
+
|
|
284
|
+
// eslint-disable-next-line max-params
|
|
285
|
+
export function getChildStyle(child, index, calculatedProps, theme) {
|
|
282
286
|
const {
|
|
283
287
|
style,
|
|
284
288
|
role
|
|
@@ -288,7 +292,7 @@ export function getChildStyle(child, index, calculatedProps) {
|
|
|
288
292
|
return childStyle;
|
|
289
293
|
}
|
|
290
294
|
const childRole = child.type && child.type.role;
|
|
291
|
-
const defaultFill = childRole === "stack" ? undefined : getColor(calculatedProps, child, index);
|
|
295
|
+
const defaultFill = childRole === "stack" ? undefined : getColor(calculatedProps, child, index, theme);
|
|
292
296
|
const defaultColor = childRole === "line" ? {
|
|
293
297
|
fill: "none",
|
|
294
298
|
stroke: defaultFill
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.VictoryPortal = void 0;
|
|
7
|
+
var _uniqueId2 = _interopRequireDefault(require("lodash/uniqueId"));
|
|
7
8
|
var _defaults2 = _interopRequireDefault(require("lodash/defaults"));
|
|
8
9
|
var _react = _interopRequireDefault(require("react"));
|
|
9
10
|
var Log = _interopRequireWildcard(require("../victory-util/log"));
|
|
@@ -20,7 +21,7 @@ const VictoryPortal = initialProps => {
|
|
|
20
21
|
...defaultProps,
|
|
21
22
|
...initialProps
|
|
22
23
|
};
|
|
23
|
-
const id =
|
|
24
|
+
const id = (0, _uniqueId2.default)();
|
|
24
25
|
const portalContext = (0, _portalContext.usePortalContext)();
|
|
25
26
|
if (!portalContext) {
|
|
26
27
|
const msg = "`renderInPortal` is not supported outside of `VictoryContainer`. " + "Component will be rendered in place";
|