@@ -11,7 +11,9 @@ import { VictoryLine } from "victory-line";
11
11
import { VictoryScatter } from "victory-scatter" ;
12
12
import { VictoryTooltip } from "victory-tooltip" ;
13
13
import { VictoryLegend } from "victory-legend" ;
14
- import { VictoryTheme } from "victory-core/lib" ;
14
+ import { VictoryTheme } from "victory-core" ;
15
+
16
+ const themeColors = VictoryTheme . clean . palette ?. colors || { } ;
15
17
16
18
const Charts = ( { behaviors } ) => {
17
19
const containerStyle : React . CSSProperties = {
@@ -34,6 +36,7 @@ const Charts = ({ behaviors }) => {
34
36
{ /* A */ }
35
37
< VictoryChart
36
38
style = { chartStyle }
39
+ theme = { VictoryTheme . clean }
37
40
height = { 400 }
38
41
padding = { { top : 100 , bottom : 50 , left : 50 , right : 50 } }
39
42
domainPadding = { { y : 2 } }
@@ -58,11 +61,10 @@ const Charts = ({ behaviors }) => {
58
61
centerTitle
59
62
orientation = "horizontal"
60
63
gutter = { 20 }
61
- style = { { border : { stroke : "black" } , title : { fontSize : 20 } } }
62
64
data = { [
63
- { name : "One" , symbol : { fill : "tomato" } } ,
64
- { name : "Two" , symbol : { fill : " orange" } } ,
65
- { name : "Three" , symbol : { fill : "gold" } } ,
65
+ { name : "One" , symbol : { fill : themeColors . red } } ,
66
+ { name : "Two" , symbol : { fill : themeColors . orange } } ,
67
+ { name : "Three" , symbol : { fill : themeColors . yellow } } ,
66
68
] }
67
69
/>
68
70
< VictoryLine
@@ -74,10 +76,10 @@ const Charts = ({ behaviors }) => {
74
76
] }
75
77
style = { {
76
78
data : {
77
- stroke : "tomato" ,
79
+ stroke : themeColors . red ,
78
80
strokeWidth : ( { active } ) => ( active ? 4 : 2 ) ,
79
81
} ,
80
- labels : { fill : "tomato" } ,
82
+ labels : { fill : themeColors . red } ,
81
83
} }
82
84
/>
83
85
@@ -89,10 +91,10 @@ const Charts = ({ behaviors }) => {
89
91
] }
90
92
style = { {
91
93
data : {
92
- stroke : "blue" ,
94
+ stroke : themeColors . orange ,
93
95
strokeWidth : ( { active } ) => ( active ? 4 : 2 ) ,
94
96
} ,
95
- labels : { fill : "blue" } ,
97
+ labels : { fill : themeColors . orange } ,
96
98
} }
97
99
/>
98
100
@@ -104,10 +106,10 @@ const Charts = ({ behaviors }) => {
104
106
] }
105
107
style = { {
106
108
data : {
107
- stroke : "black" ,
109
+ stroke : themeColors . yellow ,
108
110
strokeWidth : ( { active } ) => ( active ? 4 : 2 ) ,
109
111
} ,
110
- labels : { fill : "black" } ,
112
+ labels : { fill : themeColors . yellow } ,
111
113
} }
112
114
/>
113
115
</ VictoryChart >
@@ -120,9 +122,9 @@ const Charts = ({ behaviors }) => {
120
122
labels = { ( { datum } ) => round ( datum . x , 2 ) }
121
123
cursorLabel = { ( { datum } ) => round ( datum . x , 2 ) }
122
124
selectionStyle = { {
123
- stroke : "tomato" ,
125
+ stroke : themeColors . red ,
124
126
strokeWidth : 2 ,
125
- fill : "tomato" ,
127
+ fill : themeColors . red ,
126
128
fillOpacity : 0.1 ,
127
129
} }
128
130
selectedDomain = { { x : [ 0.4 , 0.95 ] , y : [ 0.5 , 0.8 ] } }
@@ -133,7 +135,10 @@ const Charts = ({ behaviors }) => {
133
135
< VictoryScatter
134
136
style = { {
135
137
data : {
136
- fill : ( { active } ) => ( active ? "tomato" : "black" ) ,
138
+ fill : ( { active } ) =>
139
+ active
140
+ ? themeColors . red || "tomato"
141
+ : themeColors . yellow || "yellow" ,
137
142
} ,
138
143
} }
139
144
size = { ( { active } ) => ( active ? 5 : 3 ) }
@@ -151,7 +156,7 @@ const Charts = ({ behaviors }) => {
151
156
< VictoryGroup style = { chartStyle } >
152
157
< VictoryScatter
153
158
style = { {
154
- data : { fill : "tomato" } ,
159
+ data : { fill : themeColors . blue } ,
155
160
} }
156
161
size = { ( { active } ) => ( active ? 5 : 3 ) }
157
162
labels = { ( { datum } ) => datum . y }
@@ -160,11 +165,6 @@ const Charts = ({ behaviors }) => {
160
165
pointerLength = { 4 }
161
166
flyoutPadding = { { top : 8 , bottom : 8 , left : 16 , right : 16 } }
162
167
cornerRadius = { 1 }
163
- flyoutStyle = { {
164
- stroke : "#757575" ,
165
- strokeWidth : 2 ,
166
- fill : "white" ,
167
- } }
168
168
/>
169
169
}
170
170
data = { [
@@ -179,7 +179,7 @@ const Charts = ({ behaviors }) => {
179
179
/>
180
180
< VictoryScatter
181
181
style = { {
182
- data : { fill : "blue" } ,
182
+ data : { fill : themeColors . purple } ,
183
183
} }
184
184
size = { ( { active } ) => ( active ? 5 : 3 ) }
185
185
labels = { ( { datum } ) => datum . y }
@@ -188,11 +188,6 @@ const Charts = ({ behaviors }) => {
188
188
pointerLength = { 4 }
189
189
flyoutPadding = { { top : 8 , bottom : 8 , left : 16 , right : 16 } }
190
190
cornerRadius = { 1 }
191
- flyoutStyle = { {
192
- stroke : "#757575" ,
193
- strokeWidth : 2 ,
194
- fill : "white" ,
195
- } }
196
191
/>
197
192
}
198
193
data = { [
@@ -206,6 +201,9 @@ const Charts = ({ behaviors }) => {
206
201
] }
207
202
/>
208
203
< VictoryScatter
204
+ style = { {
205
+ data : { fill : themeColors . green } ,
206
+ } }
209
207
data = { [
210
208
{ x : 1 , y : 5 } ,
211
209
{ x : 2 , y : - 4 } ,
@@ -221,11 +219,6 @@ const Charts = ({ behaviors }) => {
221
219
pointerLength = { 4 }
222
220
flyoutPadding = { { top : 8 , bottom : 8 , left : 16 , right : 16 } }
223
221
cornerRadius = { 1 }
224
- flyoutStyle = { {
225
- stroke : "#757575" ,
226
- strokeWidth : 2 ,
227
- fill : "white" ,
228
- } }
229
222
/>
230
223
}
231
224
size = { ( { active } ) => ( active ? 5 : 3 ) }
@@ -234,20 +227,14 @@ const Charts = ({ behaviors }) => {
234
227
</ VictoryChart >
235
228
{ /* D */ }
236
229
< VictoryStack
230
+ theme = { VictoryTheme . clean }
237
231
style = { chartStyle }
238
232
containerComponent = {
239
233
< CustomContainer selectedDomain = { { x : [ 1.5 , 2.5 ] , y : [ - 3 , 4 ] } } />
240
234
}
241
235
>
242
236
< VictoryBar
243
- style = { {
244
- data : {
245
- fill : "tomato" ,
246
- stroke : ( { active } ) => ( active ? "black" : "none" ) ,
247
- strokeWidth : 2 ,
248
- } ,
249
- } }
250
- barWidth = { ( { active } ) => ( active ? 5 : 3 ) }
237
+ barWidth = { ( { active } ) => ( active ? 10 : 8 ) }
251
238
data = { [
252
239
{ x : 1 , y : - 5 } ,
253
240
{ x : 2 , y : 4 } ,
@@ -259,14 +246,7 @@ const Charts = ({ behaviors }) => {
259
246
] }
260
247
/>
261
248
< VictoryBar
262
- style = { {
263
- data : {
264
- fill : "orange" ,
265
- stroke : ( { active } ) => ( active ? "black" : "none" ) ,
266
- strokeWidth : 2 ,
267
- } ,
268
- } }
269
- barWidth = { ( { active } ) => ( active ? 5 : 3 ) }
249
+ barWidth = { ( { active } ) => ( active ? 10 : 8 ) }
270
250
data = { [
271
251
{ x : 1 , y : - 3 } ,
272
252
{ x : 2 , y : 5 } ,
@@ -278,13 +258,7 @@ const Charts = ({ behaviors }) => {
278
258
] }
279
259
/>
280
260
< VictoryBar
281
- style = { {
282
- data : {
283
- fill : "gold" ,
284
- stroke : ( { active } ) => ( active ? "black" : "none" ) ,
285
- strokeWidth : 2 ,
286
- } ,
287
- } }
261
+ barWidth = { ( { active } ) => ( active ? 10 : 8 ) }
288
262
data = { [
289
263
{ x : 1 , y : 5 } ,
290
264
{ x : 2 , y : - 4 } ,
0 commit comments