Skip to content

Commit f91750c

Browse files
authored
Merge pull request #466 from FormidableLabs/support-victory-container
Support victory container
2 parents cd38376 + d38c1b7 commit f91750c

File tree

5 files changed

+142
-5
lines changed

5 files changed

+142
-5
lines changed

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Victory Changelog
22

3+
## 0.15.0 (2017-01-03)
4+
5+
- Adds `VictorySelectionContainer`
6+
- Changes when functional styles and props are evaluated (this may be a breaking change)
7+
Functional styles and props are now evaluated in the primitive components (`Point`, `Bar` etc.)
8+
- Supports an `active` prop on all primitive components that is used when evaluating functional styles and props
9+
- Tooltips now trigger `active: true` on both labels and data components
10+
- `defaultEvents` are supported for `containerComponents`
11+
312
## 0.14.2 (2016-12-13)
413

514
- Fixes date handling in VictoryZoom

demo/demo.js

+126-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import {
66
VictoryChart,
77
VictoryLine,
88
VictoryPie,
9-
VictoryScatter
9+
VictoryScatter,
10+
VictoryStack,
11+
VictoryGroup,
12+
VictorySelectionContainer
1013
} from "../src/index";
1114

1215
export default class App extends React.Component {
@@ -26,6 +29,7 @@ export default class App extends React.Component {
2629

2730
<h3>VictoryChart</h3>
2831
<p>Line chart of function <code>y = x^2</code></p>
32+
2933
<VictoryChart style={style}>
3034
<VictoryLine y={(data) => data.x * data.x}/>
3135
</VictoryChart>
@@ -156,6 +160,127 @@ export default class App extends React.Component {
156160
<p>Default props</p>
157161
<VictoryArea style={style}/>
158162

163+
<h3>VictorySelectionContainer</h3>
164+
165+
<VictoryGroup style={style}
166+
containerComponent={
167+
<VictorySelectionContainer
168+
selectionStyle={{
169+
stroke: "tomato", strokeWidth: 2, fill: "tomato", fillOpacity: 0.1
170+
}}
171+
/>
172+
}
173+
>
174+
<VictoryScatter
175+
style={{
176+
data: {fill: "tomato"}
177+
}}
178+
size={(datum, active) => active ? 5 : 3}
179+
data={[
180+
{x: 1, y: -5},
181+
{x: 2, y: 4},
182+
{x: 3, y: 2},
183+
{x: 4, y: 3},
184+
{x: 5, y: 1},
185+
{x: 6, y: -3},
186+
{x: 7, y: 3}
187+
]}
188+
/>
189+
<VictoryScatter
190+
style={{
191+
data: {fill: "blue"}
192+
}}
193+
size={(datum, active) => active ? 5 : 3}
194+
data={[
195+
{x: 1, y: -3},
196+
{x: 2, y: 5},
197+
{x: 3, y: 3},
198+
{x: 4, y: 0},
199+
{x: 5, y: -2},
200+
{x: 6, y: -2},
201+
{x: 7, y: 5}
202+
]}
203+
/>
204+
<VictoryScatter
205+
data={[
206+
{x: 1, y: 5},
207+
{x: 2, y: -4},
208+
{x: 3, y: -2},
209+
{x: 4, y: -3},
210+
{x: 5, y: -1},
211+
{x: 6, y: 3},
212+
{x: 7, y: -3}
213+
]}
214+
size={(datum, active) => active ? 5 : 3}
215+
/>
216+
</VictoryGroup>
217+
218+
<VictoryStack style={style}
219+
containerComponent={
220+
<VictorySelectionContainer
221+
selectionStyle={{
222+
stroke: "tomato", strokeWidth: 2, fill: "tomato", fillOpacity: 0.1
223+
}}
224+
/>
225+
}
226+
>
227+
<VictoryBar
228+
style={{
229+
data: {
230+
fill: "tomato",
231+
stroke: (d, active) => active ? "black" : "none",
232+
strokeWidth: 2
233+
}
234+
}}
235+
size={(datum, active) => active ? 5 : 3}
236+
data={[
237+
{x: 1, y: -5},
238+
{x: 2, y: 4},
239+
{x: 3, y: 2},
240+
{x: 4, y: 3},
241+
{x: 5, y: 1},
242+
{x: 6, y: -3},
243+
{x: 7, y: 3}
244+
]}
245+
/>
246+
<VictoryBar
247+
style={{
248+
data: {
249+
fill: "orange",
250+
stroke: (d, active) => active ? "black" : "none",
251+
strokeWidth: 2
252+
}
253+
}}
254+
size={(datum, active) => active ? 5 : 3}
255+
data={[
256+
{x: 1, y: -3},
257+
{x: 2, y: 5},
258+
{x: 3, y: 3},
259+
{x: 4, y: 0},
260+
{x: 5, y: -2},
261+
{x: 6, y: -2},
262+
{x: 7, y: 5}
263+
]}
264+
/>
265+
<VictoryBar
266+
style={{
267+
data: {
268+
fill: "gold",
269+
stroke: (d, active) => active ? "black" : "none",
270+
strokeWidth: 2
271+
}
272+
}}
273+
data={[
274+
{x: 1, y: 5},
275+
{x: 2, y: -4},
276+
{x: 3, y: -2},
277+
{x: 4, y: -3},
278+
{x: 5, y: -1},
279+
{x: 6, y: 3},
280+
{x: 7, y: -3}
281+
]}
282+
/>
283+
</VictoryStack>
159284
</div>
160285
);
161286
}

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
"dependencies": {
3535
"builder": "^3.1.0",
3636
"builder-victory-component": "^3.1.0",
37-
"victory-chart": "^14.0.3",
38-
"victory-core": "^10.0.2",
39-
"victory-pie": "^7.2.0"
37+
"victory-chart": "^15.0.0",
38+
"victory-core": "^11.0.0",
39+
"victory-pie": "^9.0.0"
4040
},
4141
"devDependencies": {
4242
"builder-victory-component-dev": "^3.1.0",

src/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ import {
2727
VictoryStack,
2828
VictoryVoronoi,
2929
VictoryVoronoiTooltip,
30-
VictoryZoom
30+
VictoryZoom,
31+
VictorySelectionContainer
3132
} from "victory-chart";
3233

3334
import { VictoryPie } from "victory-pie";
@@ -58,6 +59,7 @@ export {
5859
VictoryPortal,
5960
Portal,
6061
VictoryClipContainer,
62+
VictorySelectionContainer,
6163
addEvents, Collection, Data, DefaultTransitions, Domain, Events, Helpers, Log,
6264
PropTypes, Scale, Style, TextSize, Transitions
6365
};

test/client/spec/components/victory.spec.js

+1
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,6 @@ describe("victory", () => {
5353
expect(Victory.TextSize).not.to.equal(undefined);
5454
expect(Victory.Transitions).not.to.equal(undefined);
5555
expect(Victory.VictoryZoom).not.to.equal(undefined);
56+
expect(Victory.VictorySelectionContainer).not.to.equal(undefined);
5657
});
5758
});

0 commit comments

Comments
 (0)