-
Notifications
You must be signed in to change notification settings - Fork 526
/
Copy pathcontainers-and-addons.js
125 lines (121 loc) · 4.34 KB
/
containers-and-addons.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*eslint-disable no-magic-numbers*/
import React from "react";
import { storiesOf } from "@storybook/react";
import { VictoryChart } from "../packages/victory-chart/src/index";
import { VictoryAxis } from "../packages/victory-axis/src/index";
import { VictoryLine } from "../packages/victory-line/src/index";
import { VictoryZoomContainer } from "../packages/victory-zoom-container/src/index";
import { VictoryCursorContainer } from "../packages/victory-cursor-container/src/index";
import { VictoryBrushContainer } from "../packages/victory-brush-container/src/index";
import { VictoryBrushLine } from "../packages/victory-brush-line/src/index";
// only add visual test for containers that have visual elements without interaction
storiesOf("Containers and Addons.VictoryBrushContainer", module)
.add("with VictoryBrushContainer", () => (
<VictoryChart containerComponent={<VictoryBrushContainer />} />
))
.add("with VictoryBrushContainer with domain", () => (
<VictoryChart
containerComponent={<VictoryBrushContainer brushDomain={{ x: [0, 0.5], y: [0.5, 1] }} />}
/>
))
.add("with VictoryBrushContainer with domain (horizontal)", () => (
<VictoryChart
horizontal
containerComponent={<VictoryBrushContainer brushDomain={{ x: [0, 0.5], y: [0.5, 1] }} />}
/>
))
.add("with VictoryBrushContainer with brushStyle", () => (
<VictoryChart
containerComponent={
<VictoryBrushContainer brushStyle={{ fill: "teal", stroke: "teal", fillOpacity: 0.2 }} />
}
/>
));
storiesOf("Containers and Addons.VictoryBrushLine", module)
.add("brush axis", () => <VictoryAxis axisComponent={<VictoryBrushLine />} />)
.add("brush axis with initial brush", () => (
<VictoryAxis axisComponent={<VictoryBrushLine brushDomain={[0.25, 0.5]} />} />
))
.add("brush gridline", () => <VictoryAxis gridComponent={<VictoryBrushLine />} />)
.add("brush gridline with initial brushes", () => (
<VictoryAxis gridComponent={<VictoryBrushLine brushDomain={[0.25, 0.5]} />} />
))
.add("brush gridline with styles", () => (
<VictoryAxis
gridComponent={
<VictoryBrushLine
brushDomain={[0.25, 0.5]}
brushAreaStyle={{ fill: "orange", stroke: "tomato", strokeWidth: 2 }}
brushStyle={{ fill: "teal", stroke: "navy", strokeWidth: 2 }}
handleStyle={{ strokeWidth: 1, stroke: "grey" }}
/>
}
/>
))
.add("brush gridline with widths", () => (
<VictoryAxis
gridComponent={
<VictoryBrushLine
brushDomain={[0.25, 0.5]}
brushWidth={40}
brushAreaWidth={20}
handleWidth={4}
brushAreaStyle={{ fill: "orange", stroke: "tomato", strokeWidth: 2 }}
brushStyle={{ fill: "teal", stroke: "navy", strokeWidth: 2 }}
handleStyle={{ strokeWidth: 1, stroke: "grey" }}
/>
}
/>
));
storiesOf("Containers and Addons.VictoryCursorContainer", module)
.add("with VictoryCursorContainer with defaultCursorValue", () => (
<VictoryChart
containerComponent={
<VictoryCursorContainer
cursorLabel={({ datum }) => datum.x}
defaultCursorValue={{ x: 0.25, y: 0.75 }}
/>
}
/>
))
.add("with VictoryCursorContainer with defaultCursorValue (horizontal)", () => (
<VictoryChart
horizontal
containerComponent={
<VictoryCursorContainer
cursorLabel={({ datum }) => datum.x}
defaultCursorValue={{ x: 0.25, y: 0.75 }}
/>
}
/>
));
storiesOf("Containers and Addons.VictoryZoomContainer", module).add(
"with VictoryZoomContainer with initial zoom",
() => (
<VictoryChart
scale={{ x: "time" }}
containerComponent={
<VictoryZoomContainer
zoomDomain={{ x: [new Date(1993, 1, 1), new Date(2005, 1, 1)] }}
dimension="x"
/>
}
>
<VictoryLine
style={{
data: { stroke: "red", strokeWidth: 5 }
}}
data={[
{ x: new Date(1982, 1, 1), y: 125 },
{ x: new Date(1987, 1, 1), y: 257 },
{ x: new Date(1993, 1, 1), y: 345 },
{ x: new Date(1997, 1, 1), y: 515 },
{ x: new Date(2001, 1, 1), y: 132 },
{ x: new Date(2005, 1, 1), y: 305 },
{ x: new Date(2011, 1, 1), y: 270 },
{ x: new Date(2015, 1, 1), y: 470 }
]}
/>
</VictoryChart>
)
);